It’s PHP 7.2 that is trending these days and we will make sure that you are always up to the trend mark and never behind! In this article, you will be learning ways in which you can check if your custom Magento code is compatible with PHP version 7.2 or not.
Step 1 : Set up PHP_CodeSniffer and PHPCompatibility
To start with, you need to set up PHP_CodeSniffer on the system. You can set it up using the link given below:
After successful installation of PHP_CodeSniffer starts installing PHPCompatibility on the system using the following link.
Note: PHPCompatibility with version > 8.0 will only work with PHP version 7.1. Do make sure you have installed PHP version 7.1 on your system.
Step 2 : Execute commands to check compatibility
Now, to proceed further you need to execute commands to check the compatibility.
Go the desired folder (which needs to checked) using the command line and execute the command given below:
phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 7.2
Note: In the above command you can change testversion if you want to check with a different version of PHP.
Above command will give its result as an output in the console itself. If you want to save the result in a specific result file you can do it with the following command:
phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 7.2 --report-full=<Full path of result file>