Modified:2017-12-15  Published:2017-12-15  Views: 12208
Author: hasanuzzaman
Published in: Dolibarr
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

10  
1  
1  
1  
0  
6  
0  
85  
7  

There are zero sub-categories in this parent category.

127  
4  
63  
6  
3  
3  
10  
5  
9  
4  
12  
6  
3  
0  
1  
73  
16  
1  
1  
25  
2  
2  
0  
2  
1  
2  
2  
7  
0  
1  
0  
2  
2  
2  
13  
2  
1  
3  
2  
1  
0  
2  
3  
3  
0  
1  
5  
0  
3  
4  
1  
17  
62  
2  
1  
0  
1  
0  
0  
6  
1  
1  
41  
1  
1  
2  
0  
12  
0  
0  
0  
0  
7  
3  
0  
2  
2  
2  

There are zero sub-categories in this parent category.

4  
1  
5  
6  
0  
3  
2  
1  
0  
2  
1  
2  
0  
4  
2  
0  
5  
1  
26  
1  

There are zero sub-categories in this parent category.

0  
1  
0  
1  
0  
1  
0  
1  
0  
0  
0  
2  
31  
1  
20  
3  
2  
0  
0  
0  
0  
1  
1  
0  
1  
0  
0  
0  
1  
0  
46  
0  
1  
5  
0  
2  
2  
0  
0  
0  
0  
2  
10  
2  

Sponsor