Skip to main content

PHP compatibility checking with phpcs

PHP 8.5 will be the next version of PHP, scheduled for release this November.

There are new features being added, including the |> pipe operator, that I'll look forward to using.

Once it's released, how can you tell if your application code is compatible?

Or, if you're stuck on an older version of PHP, how do you know if you can upgrade?

Running your automated tests is a great first step.

Another check is to use PHP CodeSniffer, aka (phpcs).

As well as coding standards, it can also run PHP compatibility checks.

With the PHP Compatibility Coding Standard installed, running phpcs -p . --standard=PHPCompatibility will perform the compatibility check and show any errors.

To specify a version of PHP to test against, add --runtime-set testVersion 8.5 using the desired version.

If you need to make changes, I recommend using Rector and have it make the changes automatically.

Was this interesting?

Subscribe to my daily newsletter for software professionals on software development and delivery, Drupal, DevOps, community, and open-source.

About me

Picture of Oliver

I'm a certified Drupal Triple Expert and former Drupal Association staff member with 18 years of experience, a Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.