2015-05-28

Upgrading PHP versions


PHP versions upgrade have been picking up a regular pace : for the past years we've had a new version every year. Support has been limited to 2 years for each version plus one year of security fix.
The PHP4 years are far behind, now we feel that PHP developer can freely move forward in versions.

Upgrading in PHP requires generally little efforts thanks to a great ascending compatibility. Features that will be removed are usualy deprecated for one or two versions but still available, which gives us plenty of time to plan ahead.

Now if you have a huge code base, like we have at Planon, you'd want to see easily how much effort/risk is involved with upgrades. This usualy means reading the change log and checking how this affects your code base. Luckily for you there is a tool that can help you with this.

PHPComptibility

Provided by Wim Godden from Cu.be Solutions, this is a smart PHP CodeSniff to check against a certain version of PHP.

All you need is to, if you have not done so already,  install PHPCS. then add the sniff he created into you pear/php/CodeSniffer/Standards.
Finaly you execute it simply by :
phpcs /your/project/dir --standard=PHPCompatibility --runtime-set testVersion 5.5

Then you'll obtain a list of errors and warnings that you'd need to fix.

This has proven very handy to track down some errors we had missed when manually reviewing the code.

You may even use this to make sure your development team does not use old, deprecated features.

Links:

PHPCompatibility: https://github.com/wimg/PHPCompatibility
Php versions : http://php.net/supported-versions.php


No comments: