Run PHP Compatibility checks for upgrading version


In order to bring the PHP version up to date, we need to run compatibility test on our projects.


The CodeSniffer tool that can be installed on each system gives us the most precise results. Follow the guide to have the CodeSniffer up and running (skip the steps you don’t require):

1. CodeSniffer requires PEAR, so if you don’t have it, you can install it:

$ pear

This should output the manual, or if it is not installed, the “unknown command” error. For the latter, you need to install PEAR:

$ lynx -source | php

Now PEAR is installed.

2. Install the CodeSniffer (first check with command $ phpcs if is not already there):

pear install PHP_CodeSniffer-2.0.0a1

3. Add the PHPCompatibility standard to CodeSniffer:

cd /usr/share/php/PHP/CodeSniffer/Standards
git clone git:// PHPCompatibility

4. Go to your project and run the compatibility tests:

phpcs –standard=PHPCompatibility –extensions=php,phtml *

If you receive “Fatal error: Maximum function nesting level of ‘100’ reached, aborting!”, you need to add/edit the value of xdebug.max_nesting_level in your php.ini file:

$ locate php.ini

$ vim /etc/php5/cgi/php.ini

xdebug.max_nesting_level = 1000

xdebug.max_nesting_level of 1000 should be enough for any medium to big size project.

5. Read and fix the errors presented in the output of the test



About admin

Just another php developer trying to give something back to the community.
This entry was posted in Best practices, Linux, PhP and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s