Chapters Close

How to check your code is compatible with PHP?

Sep 22nd, 2018 3 min to read

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>


What is PHP compatibility?

PHP compatibility is the ability of a code to run with the support of a particular PHP version. New PHP versions and even patches support different features which limits the ability of certain scripts to run with newer or older versions. You can check the compatibility of a particular script using the command php -l before deploying it.

Is Magento 2 compatible with PHP 8?

No, Magento 2 is not compatible with PHP 8. However, the Magento community is working to develop a Magento codebase that is compatible with the version of PHP. The project is unofficially labeled as Magento PHP 8 Compatibility Community Project and works on crowd contribution to onboard Magento 2 to PHP 8.

Does Magento use PHP?

Yes, Magento uses PHP as its programming language. It is an open-source platform whose server-side code is developed through various PHP frameworks such as Laminas, Symphony, and Zend. Though it also uses other languages such as MySQL, the code is majorly based on PHP alone.

Does Magento 2.4 support PHP 8?

Yes, magento 2.4 supports PHP 8. The main feature of the Magento 2.4 version was its ability to run on PHP 8. This is also the official version of Magento 2 that is compatible with PHP 7.4 and above as earlier Magento 2 versions were made compatible only with a community-sourced project.

Speak your Mind

Post a Comment

Got a question? Have a feedback? Please feel free to leave your ideas, opinions, and questions in the comments section of our post! ❤️

* This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Grow your online business like 4,652 subscribers

    * This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

    Thank You!

    We are reviewing your submission, and will be in touch shortly.