PHP 8.2, 8.3, and 8.4 Compatibility with Magento 2.4.x
Running Magento 2 on an unsupported PHP version causes errors ranging from deprecation warnings to fatal crashes. Each Magento release is tested and certified for specific PHP versions. Using the correct combination ensures stability, performance, and access to security updates.
Version Compatibility Matrix
| Magento Version | PHP 7.4 | PHP 8.1 | PHP 8.2 | PHP 8.3 | PHP 8.4 |
|---|---|---|---|---|---|
| 2.4.4 | Yes | Yes | No | No | No |
| 2.4.5 | No | Yes | No | No | No |
| 2.4.6 | No | Yes | Yes | No | No |
| 2.4.7 | No | No | Yes | Yes | No |
| 2.4.8 | No | No | Yes | Yes | Yes* |
*PHP 8.4 support in 2.4.8 may require patches for certain modules. Verify with release notes.
When upgrading Magento, also plan the PHP upgrade if needed. Running a newer PHP version than officially supported can work in many cases but is not covered by Adobe support and may trigger unexpected behavior in edge cases.
PHP 8.2 Compatibility
Deprecated Dynamic Properties
PHP 8.2 deprecates the creation of dynamic properties (setting a class property that was not declared). This is the most common issue when upgrading from PHP 8.1 to 8.2.
Symptoms:
Deprecated: Creation of dynamic property ClassName::$propertyName is deprecated
This affects both Magento core (in versions before 2.4.6) and many third-party extensions. While deprecation warnings are non-fatal and the code still functions, they fill error logs and may cause issues with strict error reporting.
Solutions:
- Upgrade Magento to 2.4.6+ which includes fixes for core dynamic property usage
- Update third-party extensions to versions that support PHP 8.2
- For custom code, declare properties explicitly or use the
#[AllowDynamicProperties]attribute as a temporary workaround
Readonly Classes
PHP 8.2 introduces readonly classes. While Magento core does not use them yet, extensions that target PHP 8.2+ may. Ensure your code analysis tools support the syntax.
PHP 8.3 Compatibility
PHP 8.3 is supported starting with Magento 2.4.7. Key changes that may affect extensions:
json_validate()function added (no conflict, but enables improved validation)- Typed class constants
#[Override]attribute for documenting method overrides- Changes to
unserialize()error handling (warnings become exceptions in some cases)
Most well-maintained extensions work on PHP 8.3 without changes. Test thoroughly in staging.
PHP 8.4 Compatibility
PHP 8.4 support begins with Magento 2.4.8. Notable changes:
- Dynamic properties (deprecated in 8.2) still produce warnings but are not yet removed
- Some GraphQL-related modules may have compatibility issues with PHP 8.4's stricter type handling
- Property hooks and asymmetric visibility are new features but do not affect backward compatibility
If you encounter GraphQL errors after upgrading to PHP 8.4, check whether the issue is in a Magento core module or a third-party extension. Core fixes are typically released in patch versions.
Recommended php.ini Settings
These settings are recommended for production Magento 2 installations:
memory_limit = 2G
max_execution_time = 18000
max_input_vars = 10000
post_max_size = 64M
upload_max_filesize = 64M
realpath_cache_size = 10M
realpath_cache_ttl = 7200
opcache.enable = 1
opcache.memory_consumption = 512
opcache.max_accelerated_files = 60000
opcache.validate_timestamps = 0
opcache.consistency_checks = 0
opcache.save_comments = 1
Key notes:
memory_limit = 2Gis the minimum for compilation and deployment. Individual CLI commands may need more (use-d memory_limit=4Gflag).opcache.validate_timestamps = 0in production means you must clear opcache after deployment (restart PHP-FPM or runopcache_reset()).opcache.save_comments = 1is required because Magento uses annotations for dependency injection.
Checking Compatibility Before Upgrading
PHP Compatibility Checker
Use phpcompatibility/php-compatibility with PHP_CodeSniffer to scan for issues:
composer require --dev phpcompatibility/php-compatibility
vendor/bin/phpcs --standard=PHPCompatibility --runtime-set testVersion 8.3 app/code/
This scans custom modules for code patterns incompatible with the target PHP version.
Rector
For automated code migration between PHP versions:
composer require --dev rector/rector
vendor/bin/rector process app/code/ --set php82
Rector can automatically fix many deprecated patterns, including dynamic properties and older function signatures.