Upgrade to PHP 8.3
Edit on GitHubThis document describes how to upgrade PHP to version 8.3. This upgrades the version in Docker environment and composer.json
.
1. Check project code for PHP compatibility using PHPCompatibility
To make sure your project is compatible with PHP 8.3, follow the steps:
- Require the
php-compatibility
package:
composer require --dev phpcompatibility/php-compatibility --ignore-platform-reqs
- Configure
phpcs
to usephp-compatibility
rules:
vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility
- Execute the
php-compatibility
sniffer for PHP 8.3:
vendor/bin/phpcs -p src/ --standard=PHPCompatibility --runtime-set testVersion 8.3
This returns the code that’s not compatible with PHP 8.3.
- Fix all the discovered incompatibilities.
2. Check and resolve incompatible dependencies
- Identify any dependencies that are not compatible with PHP 8.3:
composer why-not php 8.3
-
Review the output. The command listed dependencies that are not compatible with PHP 8.3, along with the reasons why they can’t be upgraded.
-
Update dependencies. Check if there are newer versions of these dependencies that support PHP 8.3. You can do this by visiting the package’s repository or checking its documentation. If updates are available, update your
composer.json
file to require these newer versions. -
Resolve conflicts. If newer versions are not available, you may need to find alternative packages that are compatible with PHP 8.3. Search for alternative packages on Packagist or other package repositories.
3. Update composer.json
Modify your composer.json
file to reflect the new PHP version requirements.
- Set the minimum required PHP version to 8.3:
"require": {
"php": ">=8.3",
}
- Define PHP 8.3 as the platform version for dependency resolution:
"config": {
"preferred-install": "dist",
"platform": {
"php": "8.3.12"
},
- Update dependencies:
composer update
This updates the dependencies to the latest versions that are compatible with PHP 8.3
4. Update Docker configuration
- In all
deploy.yml
files, update the PHP image:
image:
tag: spryker/php:8.3
environment:
- Apply the changes by restarting the application:
docker/sdk boot && docker/sdk up --build
5. Test the upgrade
Thoroughly test your application to identify any issues due to the PHP version upgrade:
- Automated tests: Run unit, integration, and functional tests.
- Manual testing: Test critical application functionality.
- Monitor for deprecations: Check for deprecation notices or warnings that may arise from running on PHP 8.3.
Thank you!
For submitting the form