Easily check your code for PHP 8.2 compatibility

Last modified date

Comments: 0

At work, I have the task of upgrading all of our microservices to using PHP 8.2. This isn’t too bad; we’re running on PHP 8.0 anyway, and the PHP developers are known for pushing to retain backwards compatibility. However, the language does change and things get deprecated or tightened up, even between minor versions.

So I needed a way to check all of the microservices, but I didn’t want to go through all of them and update dependencies for checking tools – I just wanted to run something on the code.

So I made a simple Dockerfile and bash script which you can find on my GitHub repo. This uses the excellent PHPCompatibility library and puts it into a docker container. This means that I can then simply build the container (once is enough, but I run the build ever so often to get any additional changes) and run a bash script, and all of the code in a given directory is checked for compatibility; no additional changes needed!

That means I run:

docker build -t php-compatibility-checker .

which builds the image, then something like:

./runon.sh ../awesome/php/service

To which I see the output:

............................................................  60 / 226 (27%)
............................................................ 120 / 226 (53%)
............................................................ 180 / 226 (80%)
..............................................               226 / 226 (100%)


Time: 6.88 secs; Memory: 22MB

which shows me the service is fully compatible! 🙌

Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.