Published: 2017-11-30   Views: 121
Author: hasanuzzaman
Published in: Software
How To Generate The PHP DAO Class For Dolibarr ERP CRM

Dolibarr ERP CRM is a popular open source LAMP based web software. You may know more about Dolibarry from there official website. As a developer you may come to the point to develop custom Dolibarr module. Developing custom module is not complex as you think. You can get details about module development at Dolibarr wiki website. Currently I am developing a module for Dolibarr and following the tutorial at https://wiki.dolibarr.org/index.php/Module_development. After following step step method I got stuck at the point Generate the PHP DAO class. I search all over the Internet regarding this issue and found nothing about it. I found one forum regrading the issue at https://www.dolibarr.org/forum/511-creation-of-a-new-module/27044-how-to-configure-my-new-module, but the solution is not given there. After that I spent few hours and luckily I got the solution. I am posting this article here to help other guys who need this solution. To solve this problem follow these steps........

 

Download the helper class

When I am developing the module, current stable Dolibarr version is 6.0.3. This current version does not include the required class file, build_class_from_table.php. You need to download the file from https://github.com/thehawk970/dolibarr. After downloading the zip file called, dolibarr-master.zip unzip into your computer. Now copy the dev directory into your Dolibarr root directory. Dolibarr PHP DAO classThe screenshot is attached.

Generate DAO Class from Command Line

Now open your command line in Linux or Windows system. If you are on Linux system then you can easily run PHP command using command line. But running PHP from Windows system is slightly complex. If you find any difficulty you may refer to this https://stackoverflow.com/questions/15597067/how-to-run-php-from-windows-command-line/47555616#47555616. The screenshot is attached. You may got the warning PHP Warning:  require_once(C:\xampp\htdocs\dolibarr\dev\skeletons/../../htdocs/master.inc.php): failed to open stream: No such file or directory while you typing the command. Don't worry this is an simple warning. Open the file build_class_from_table.php in your favorite editor and go to line number 36. From there remove htdocs from the path. Now run the command and it should work now.

 

 


***** build_class_from_table.php (3.2) *****
Tablename=llx_aldictionary_configuration
Current dir is C:\xampp\htdocs\dolibarr\dev\skeletons
Error: Failed to get description for table 'llx_aldictionary_configuration'.

 

 

 

 

 

You may find the above problem while running the command again. This is because you have not enabled your Dolibarr module from module management section. Just go to Dolibarr module setup enable your development module. Now run the command and you are done. If everything goes successful you will see the following output.

 

***** build_class_from_table.php (3.2) *****
Tablename=llx_aldictionary_configuration
Current dir is C:\xampp\htdocs\dolibarr\dev\skeletons

File 'out.aldictionaryconfiguration.class.php' has been built in current directory.
File 'out.aldictionaryconfiguration_script.php' has been built in current directory.
File 'out.aldictionaryconfiguration_page.php' has been built in current directory.
You can now rename generated files by removing the 'out.' prefix in their name and store them in a directory of your choice.

c:\xampp\htdocs\dolibarr\dev\skeletons>

 

 

Note: Still if you face any problem make sure the database table is created within Dolibarr database. To need help you can contact us.

 

Article Comments

0 comments.

There are zero comments yet, why not be the first?

You must be logged in to post a comment.

Please log in or register to comment or reply to a comment.

Articles Search

Featured Articles

Most Popular Articles

Article Categories Expand

1  
1  
1  
1  
0  
6  
0  
52  
42  
6  
3  
3  
7  
4  
8  
3  
1  
1  
0  
0  
0  
12  
0  
0  
0  
1  
2  
8  
1  
1  
0  
1  
1  
0  
1  
1  
0  
0  
1  
4  
0  
3  
3  
0  
24  
1  
0  
0  
0  
2  
1  
0  
0  
6  
0  
1  
25  
1  
0  
2  
0  
11  
0  
0  
0  
0  
2  
2  
0  
2  
2  
3  
1  
2  
5  
0  
3  
1  
1  
0  
0  
1  
0  
1  
2  
0  
1  
0  
17  
0  

There are zero sub-categories in this parent category.

0  
1  
0  
0  
0  
0  
0  
1  
0  
0  
0  
1  
23  
17  
3  
1  
0  
0  
0  
0  
1  
1  
0  
0  
0  
0  
0  
1  
0  
0  
1  
3  
0  
0  
0  
0  
0  
0  
0  
1  
1  
0