Innovate faster and cut risk with PHP experts from Zend Services.
Beginning to advanced PHP classes to learn and earn global certification.
Help me choose >
Submit support requests and browse self-service resources.
Note: this workflow is a general guide. Use your judgement based on your specific use case.
Set up two environments to run the code: the current version, and the one to which you want to upgrade. We'll refer to these environments as "baseline" and "upgrade" respectively. They should be as similar as possible, except for the PHP version. You may encounter problems at this stage:
Enable all error reporting, including notices. This is important because many of these notices will become warnings or even fatal errors in newer PHP versions. By suppressing notices, you would only make it harder to debug compatibility issues.
A great way to find incompatibilities is to use an automated tool called PHPCompatibility. It will scan your code and will give you a comprehensive report of the problems that it has found.
If you run it with the -s flag, then the report will also give you the names of the sniffs, which your can use to navigate the list of incompatibilities.
will output a report with the sniff name in parentheses:
Please note that despite PHPCompatibility being an amazing tool, it does not replace thorough testing. It does not guarantee to detect every possible problem, nor can it vouch for the correctness of your fixes.
Tip: it would be prudent to write an automated test suite before undertaking a PHP upgrade; at the very least, a high-level acceptance test suite would be invaluable to ensure a successful upgrade.
If some issues went unaddressed despite a successful upgrade, you may choose to ignore them in the code analysis. You can achieve that by creating a phpcs.xml file such as this one:
<!-- see: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset -->
<!-- Allow specific extensions, as to not scan files that don't have any PHP in them -->
<arg name="extensions" value="php,inc,html,tpl"/>
<!-- Exclude a folder -->
<!-- Exclude a file -->
<!-- Ignore empty files, should you be required to keep them -->
<!-- Ignore mixed line endings, should fixing them cause other problems -->
<!-- Disable a sniff -->
<!-- Disable a sniff, but only for certain files -->
Increase security and cut risk by simplifying PHP application upgrades and migrations.
Long Term Support buys organizations time to migrate.