Code sniffers

PHP code sniffers

We recommend the consistent use of a code sniffer to enhance the readability of your code and help ensure that it meets Magento code standards. A code sniffer is a tool that automates the process of identifying code irregularities. Although a sniffer will identify many more inconsistencies and errors than a manual edit, we recommend that you evaluate and make any fixes that your sniffer program identifies.

Magento recommends the use of PHP_CodeSniffer, the most popular code sniffer in use throughout the PHP development community. PHP_CodeSniffer 1.4.0+ includes PSR-1 and PSR-2 standards, which are followed by Magento 2. You can configure PHP_CodeSniffer to use your own rules, too. The Magento Extension Quality Program Coding Standard provides specifications that you can use to configure your code sniffer of choice to bring your PHP coding style closer to Magento PHP standards.

Code standards

Magento supports the PSR-1 and PSR-2 standards.

The Coding standards overview introduces Magento-specific practices for PHP, JavaScript, and JQuery .