PHP 8 Compatibility Check

Daniel Opitz
Daniel Opitz
22 Dec 2020

To check whether your code is compatible with PHP 8 or not, you may find this tool very useful.

The PHP Compatibility Coding Standard for PHP CodeSniffer contains a set of sniffs for PHP CodeSniffer that checks for PHP cross-version compatibility. It will allow you to analyze your code for compatibility with higher and lower versions of PHP.


If not already installed, install PHP CodeSniffer first:

composer require squizlabs/php_codesniffer --dev

Then install the “PHPCompatibility” rules using this command:

composer require phpcompatibility/php-compatibility @develop --dev

Add a custom script in the correct place in your composer.json file. It should be added in the “scripts” section as follows:

"scripts": {
    "sniffer:php8": "phpcs -p ./src --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --runtime-set testVersion 8.2"


To check your codebase for PHP 8.2 compatibility issues execute the script as follows:

composer sniffer:php8

Example Output