This project is full sources of Dolibarr ERP and CRM application. Every modification must respect:
- Dolibarr's modular architecture
- Compatibility with upstream updates
- Modern PHP best practices
- ❌ Do not break compatibility of PHP functions and methods
- ❌ Do not introduce external dependencies without validation
- ❌ Separate page actions in the
/* Actions */section of the PHP code and the rendering part in the/* Views */section - ✅ Use Dolibarr hooks whenever possible
- ✅ Respect existing naming conventions
Module structure:
htdocs/mymodule
├── core/
├── class/
├── lib/
├── sql/
├── tpl/
└── admin/
A template of a module directory content can be found in the htdocs/modulebuilder/template folder of this project.
- PHP >= 7.3
- Respect PSR-12, but indentations must be Tabs and not Spaces
- Short, readable, and testable functions
- Avoid side effects
- Use Dolibarr database functions (Databese driver is global
$dbin pages or$this->dbin classes) - ✅ Always escape user inputs
- ✅ SQL forged by PHP must escape fields with db->escape(), db->sanitize() or by forcing the cast of the value into an (int) or (float).
- ✅ SQL scripts for table and index creation must be in
htdocs/install/mysql/tables/(see existing files for examples)
- Prioritize hooks over overrides
- Name hooks clearly
Before any modification:
- Verify:
- creation / edition / deletion
- user rights
- multi-entity compatibility
- If possible:
- add a PHP unit file for test
- Respect Dolibarr UI (no wild redesigns)
- Reuse existing components
- ❌ No overly complex inline JS
- ✅ JS in separate files
- Always validate inputs (
GET,POST) viaGETPOST() - Avoid SQL / XSS injections
- Use Dolibarr CSRF tokens in POST forms
- Use
dol_syslog()for logging - Do not leave
var_dump/diein code
- One branch per major version (Fix only) and one for
develop(Fix and new features) - Clear commits starting with
NEW,CLOSE, orFIX
- Read this file before any modification
- Check if an equivalent function already exists
- Minimize the impact of changes
- Propose modular modifications
- Massive refactoring without explicit request
- Change the global architecture
- Delete code without justification
- Add external dependencies
👉 Always prioritize: extension > modification
- Keep it simple
- Be conservative
- Ask for confirmation before any critical change