Quick and portable PHP compatibility check

For mission critical applications you need a lot more care, but for that simple side-gig or personal project this simple one-shot script will give a good idea of any major compatibility issues with a given PHP version. There’s no dependencies other than bash, PHP, Wget and tar so it should run on almost any linux web server.

Quick start

Please review the code before running, then if you’re happy you can download and execute with bash <(wget -qO- https://gist.githubusercontent.com/phlbnks/48c1cc71d8bba3e4558488c3a7cb9bde/raw/66182b458359cc038c08c8eaf2a9ad26313cc71c/phpcompatabilitychecker.sh)

What it’s doing

The script is just a simple wrapper for PHP Codesniffer. It downloads it, sets it up, and runs the ‘PHPCompatibility’ standard (test). It is populated with some defaults:

  • scan the /var/www directory
  • excluding folders matching the pattern */vendor/*,*/sites/*,*/tests/*
  • for compatibility with PHP8.1

However you’re asked to accept, or modify, all these at the start so you can easily customise it without needing to modify the script



Leave a Reply

Your email address will not be published. Required fields are marked *