Table of Contents
-
Introduction
-
The Relationship Between Dolibarr and PHP
-
Supported PHP Versions for Dolibarr (2023–2025)
-
Common PHP Compatibility Problems in Dolibarr
-
Diagnosing PHP Issues with Dolibarr
-
Understanding Error Logs and Warning Types
-
Upgrading or Downgrading PHP Safely for Dolibarr
-
Adjusting PHP Configuration for Dolibarr
-
Fixing Dolibarr Errors Caused by PHP Changes
-
How Custom Modules and Templates Break with PHP Updates
-
Development Best Practices for PHP Compatibility
-
How to Future-Proof Your Dolibarr Instance
-
Final Thoughts
1. Introduction
Dolibarr ERP & CRM is a robust, open-source business management platform designed to serve the evolving needs of freelancers, SMEs, and even large organizations. Built using PHP, Dolibarr relies entirely on the PHP runtime for everything—from rendering web pages to executing business logic and API endpoints.
Because of this, PHP version compatibility is not just a technical detail—it’s a foundational element that can directly impact performance, functionality, and stability.
In this article, we’ll explore how PHP and Dolibarr interact, identify common compatibility issues, walk through diagnostics and fixes, and offer best practices for keeping your system both up to date and stable.
2. The Relationship Between Dolibarr and PHP
Dolibarr is built entirely in PHP. Every single feature, module, and user interface component is processed through a PHP-based execution engine. That means the version of PHP running on your server must align with what Dolibarr supports.
If your PHP version is too old, Dolibarr may not start, or you may miss key features. If it’s too new, you could face unexpected errors, deprecated functions, and broken modules.
PHP upgrades introduce:
-
Performance improvements
-
Deprecation or removal of functions
-
Changes to default behavior (e.g., strict typing, error handling)
-
Extensions or configuration changes
-
Security fixes
Dolibarr releases are regularly updated to support newer PHP versions, but if you’re not tracking these changes carefully, you may find yourself with a broken instance after a PHP upgrade.
3. Supported PHP Versions for Dolibarr (2023–2025)
Here’s a general overview of PHP compatibility across recent Dolibarr versions:
Dolibarr Version | Minimum PHP | Recommended PHP | Max Tested PHP |
---|---|---|---|
13.x – 14.x | PHP 7.0 | PHP 7.4 | PHP 8.0 |
15.x – 17.x | PHP 7.2 | PHP 8.0 | PHP 8.1 |
18.x – 20.x | PHP 7.4 | PHP 8.0 / 8.1 | PHP 8.1 |
21.x – 22.x | PHP 8.0 | PHP 8.1+ | PHP 8.2 / 8.3 |
Future 23.x+ | PHP 8.1 | PHP 8.2+ | PHP 8.3+ |
Important: Always refer to the release notes of the specific Dolibarr version you're running before upgrading PHP.
4. Common PHP Compatibility Problems in Dolibarr
When PHP versions are not correctly aligned with Dolibarr’s requirements, the following issues may appear:
4.1 Fatal Errors
-
Example:
This happens when Dolibarr code calls a function removed in newer PHP versions (like PHP 8.0 and above).
4.2 Deprecation Warnings
-
Example:
This warning doesn’t crash the app but clutters logs and may indicate future failure points.
4.3 Module Incompatibility
-
Third-party modules written for PHP 7.x may break under PHP 8.x
-
Custom PDF templates using outdated functions can generate blank or broken documents
4.4 Unexpected Behavior
-
Broken redirects
-
Session issues (e.g., constant logouts)
-
API authentication failures
These are harder to trace but often stem from changed defaults or stricter type handling in newer PHP versions.
5. Diagnosing PHP Issues with Dolibarr
The first step to resolving compatibility problems is to accurately identify the cause.
5.1 Enable Error Reporting
In htdocs/main.inc.php
, enable error output:
This will allow you to see warnings, notices, and fatal errors directly in your browser during testing.
5.2 Check PHP Logs
PHP logs often contain more detail than browser output.
Typical locations:
-
/var/log/php-fpm.log
-
/var/log/apache2/error.log
-
/var/log/nginx/error.log
-
/var/log/php/error.log
(shared hosting)
Check for recent entries related to undefined functions
, deprecated syntax
, or memory_limit
breaches.
5.3 Use phpinfo()
Create a simple PHP file in your Dolibarr root:
Access it via browser and confirm:
-
PHP version
-
Loaded extensions
-
Configuration values (
memory_limit
,upload_max_filesize
, etc.) -
Session and timezone settings
6. Understanding Error Logs and Warning Types
Understanding the different kinds of errors PHP produces is key to effective troubleshooting. Here's a quick breakdown of the most common error types seen in Dolibarr when there's a PHP mismatch.
6.1 Fatal Errors
These stop execution immediately. Dolibarr pages may render blank or break mid-way.
Example:
6.2 Warnings
Warnings indicate a problem, but the page usually still loads.
Example:
These often appear when third-party code hasn’t been updated for new PHP versions.
6.3 Notices
Notices point to sloppy or deprecated code.
Example:
These may not affect functionality today but can become errors in future PHP versions.
6.4 Deprecated Notices
PHP flags features that will be removed soon. These notices are your early warning system.
Example:
While Dolibarr core is generally cleaned up with each release, older modules and custom code often cause these notices.
7. Upgrading or Downgrading PHP Safely for Dolibarr
Changing your PHP version can resolve issues—or create them. The key is doing it methodically.
7.1 When to Upgrade PHP
Upgrade if:
-
You're running an older PHP version (e.g. 7.2, 7.3) that’s no longer supported
-
You need better performance or security features
-
You’re moving to a newer Dolibarr version (e.g., 22.x+ requires PHP 8.0 or higher)
7.2 When to Downgrade PHP
Downgrade if:
-
You’re using legacy Dolibarr versions (e.g., v12–v14)
-
Custom modules are not compatible with PHP 8.x
-
You experience fatal errors after a PHP update
Important: Always test in a staging environment before changing PHP in production.
7.3 How to Change PHP Version (Linux CLI)
For Ubuntu/Debian:
For CentOS/RHEL:
To switch back to a previous version:
Restart the web server:
Make sure Dolibarr loads properly and all modules are accessible after the change.
8. Adjusting PHP Configuration for Dolibarr
Even with the right PHP version, bad settings can cause slow performance or unexpected errors.
Edit php.ini
to fine-tune these settings:
8.1 Enable Required Extensions
Dolibarr requires several PHP extensions. Use php -m
to check active modules.
Make sure these are enabled:
-
pdo_mysql
-
mbstring
-
curl
-
gd
-
intl
-
json
-
fileinfo
-
xml
Enable extensions via:
Then restart your web server.
9. Fixing Dolibarr Errors Caused by PHP Changes
Here’s how to fix specific Dolibarr issues triggered by PHP version mismatches:
9.1 get_magic_quotes_gpc() Undefined
This function was removed in PHP 8.0.
Fix: Upgrade Dolibarr to at least v15.x or comment out calls in custom modules.
9.2 Blank Invoices or Proposals
This is often due to outdated TCPDF or DOMPDF versions that aren’t PHP 8 compatible.
Fix:
-
Replace custom PDF templates with updated ones
-
Upgrade the
lib/pdf
orlib/tcpdf
directories -
Ensure no whitespace exists before
<?php
tags in templates
9.3 API Authentication Fails
Newer PHP versions may handle header parsing more strictly.
Fix:
-
Verify the API key is passed correctly
-
Confirm content-type headers are set
-
Re-enable web services in the Dolibarr configuration
9.4 Broken Modules or Menus
If menus disappear or modules fail to load after a PHP upgrade, it may be due to:
-
Deprecated syntax (e.g. curly brace array offsets)
-
Old-style constructors in classes
-
Missing or changed function calls
Fix:
-
Check logs
-
Disable the problematic module
-
Update the module if a newer version exists
-
Contact the module developer for a PHP 8.x update
10. How Custom Modules and Templates Break with PHP Updates
Dolibarr core evolves quickly, but custom modules often lag behind. Here’s what typically breaks:
10.1 Old PHP Syntax
Custom modules written for PHP 5 or 7 may use now-deprecated syntax.
-
create_function()
-
each()
-
Short open tags (
<?
instead of<?php
) -
Non-strict comparison
Solution: Refactor code using PHP 8 best practices and test on a staging server.
10.2 Deprecated Constructors
Older class constructors may use the class name, which is no longer valid in PHP 8:
Replace with:
10.3 PDF Templates with Obsolete Calls
Custom PDF invoice or proposal templates often use outdated methods or functions that conflict with newer versions of DOMPDF or TCPDF.
Solution:
-
Rebuild the template using the latest
pdf_model.class.php
structure -
Validate all variables and output functions
-
Avoid any direct echo or print statements outside of buffered content
11. Development Best Practices for PHP Compatibility
For those developing on or extending Dolibarr, follow these best practices to ensure compatibility with current and future PHP versions.
Use PHP 8+ in Development
Always test your modules against the latest PHP versions, even if production uses older versions.
Avoid Deprecated Features
Track deprecations using the PHP manual or tools like:
-
PHPStorm’s code inspection tools
Use Type Declarations When Possible
Type-safe code is more resilient to PHP version changes.
Structure Modules Properly
Follow Dolibarr's module skeleton and ensure you declare:
-
Hooks
-
Permissions
-
Menu entries
-
Language files
This ensures your module integrates cleanly regardless of PHP changes.
12. How to Future-Proof Your Dolibarr Instance
Always Use LTS Versions
Stick to Dolibarr releases labeled as stable or LTS to avoid regressions.
Test Before You Upgrade
Maintain a staging environment with the upcoming PHP and Dolibarr versions.
Track Compatibility Announcements
Dolibarr changelogs often include notes about PHP support. Watch for:
-
Minimum PHP version changes
-
Deprecated features
-
Compatibility-breaking core updates
Automate Compatibility Checks
Integrate static analysis tools in your CI pipeline:
-
PHPStan
-
Psalm
-
PHP_CodeSniffer (with PHPCompatibility ruleset)
13. Final Thoughts
PHP compatibility is a core concern for every Dolibarr user, from small business owners to full-stack developers. As Dolibarr evolves to take advantage of modern PHP features—improving speed, security, and code quality—you must evolve your environment with it.
A smart compatibility strategy includes:
-
Staying on supported Dolibarr versions
-
Keeping PHP up to date—but not too far ahead
-
Testing thoroughly in staging environments
-
Updating custom modules proactively
-
Following PHP development best practices
By mastering the relationship between PHP and Dolibarr, you ensure your ERP system is not only functional and fast, but also resilient and future-ready.