
Dolibarr is an open-source ERP and CRM solution known for its flexibility and modularity. Thanks to its architecture, users can add specific functionalities by developing custom modules. Whether to address specific business needs, automate tasks, or enhance the user experience, integrating a custom module into Dolibarr is an ideal solution.
In this article, we will explore step by step how to integrate a custom module into Dolibarr, from its design to its installation, development, and configuration.
1. Why Create a Custom Module for Dolibarr?
Dolibarr offers a wide range of built-in modules and extensions available on Dolistore. However, sometimes these solutions do not fully meet a company's specific requirements. Here are some reasons to create a custom module:
- Automate internal processes specific to your business.
- Add new functionalities not available in Dolibarr or existing modules.
- Modify or improve the user interface to enhance usability.
- Create connectors with other applications used within the company.
- Customize reports and dashboards for more tailored insights.
2. Prerequisites Before Integrating a Custom Module
Before starting the integration, ensure that your Dolibarr environment is ready to accept a new module.
2.1 Check Your Dolibarr Version
Each module must be compatible with your installed Dolibarr version. To check your version:
- Log in to Dolibarr as an administrator.
- Navigate to Home → Setup → System Information.
Ensure your module is compatible with this version.
2.2 Enable Developer Mode
Dolibarr has a developer mode that helps display errors and facilitates debugging:
- Go to Setup → Miscellaneous.
- Add the following line to the
conf/conf.php
file:
2.3 Access the Module Directory
All Dolibarr modules are stored in the following directory:
It is recommended to create your own modules in this directory to prevent overwriting core files during updates.
3. Developing a Custom Module for Dolibarr
A Dolibarr module mainly consists of PHP files and specific structures.
3.1 Creating the Module Structure
A Dolibarr module is organized as follows:
Explanation of directories:
- core/modules/: Contains module configuration files.
- class/: Defines the PHP classes used by the module.
- admin/: Administration interface for the module.
- script/: Additional scripts for installation or updates.
3.2 Creating the Module Configuration File
The main module file (mymodule.php
) allows Dolibarr to recognize the module:
3.3 Adding an SQL Table to Store Data
If your module needs to store specific information, create an SQL table:
The SQL script can be placed in script/install.sql and executed upon module activation.
4. Installing and Activating the Module in Dolibarr
Once your module is developed, it must be integrated into Dolibarr.
4.1 Copying the Module into Dolibarr
Place your module folder in:
4.2 Activating the Module from the Administration Panel
- Navigate to Setup → Modules/Applications.
- Search for your module in the list.
- Click Activate.
- If necessary, run any associated SQL scripts.
5. Testing and Debugging Your Module
5.1 Checking Error Logs
If your module does not function properly, check Dolibarr’s error logs in:
5.2 Enabling PHP Debug Mode
Add this line to conf/conf.php to display errors:
5.3 Conducting User Testing
- Verify if permissions work correctly.
- Test the module's interface and forms.
- Ensure compatibility with other active modules.
6. Distributing and Maintaining Your Module
If you want to share your module with the community, you can:
- Publish it on Dolistore (the marketplace for Dolibarr modules).
- Make the code available on GitHub/GitLab for collaborative updates.
- Ensure compatibility with new Dolibarr versions by testing and updating the module regularly.
Conclusion
Integrating a custom module into Dolibarr allows you to adapt the ERP to specific needs and add tailored functionalities. By following these steps—from module creation, configuration, installation, and testing—you can enhance Dolibarr without modifying its core.
With some PHP development knowledge and proper update management, you can optimize your business operations by integrating features designed specifically for your needs.
Have you ever integrated a custom module into Dolibarr? Share your experience in the comments!