MySource Matrix Developer

Main Content

PHP_CodeSniffer

Introduction

PHP_CodeSniffer is a PHP5 script that tokenises and "sniffs" PHP code to detect violations of a defined set of coding standards. It is an essential development tool that ensures that your code remains clean and consistent. It can even help prevent some common semantic errors made by developers.

A coding standard, in PHP_CodeSniffer, is a collection of sniff files. Each sniff file checks one part of the coding standard only. Multiple coding standards can be used within PHP_CodeSniffer, so that the one installation can be used across multiple projects.

PHP_CodeSniffer is part of PEAR, the PHP Extension and Application Repository. The PHP_CodeSniffer project homepage can be viewed on the PEAR website, along with download links and end-user documentation.

PHP_CodeSniffer is installed using the PEAR command line installer. Instructions for the command line installer can be found in the PEAR Manual. Replace <package> with PHP_CodeSniffer in the instructions.

For example: pear install PHP_CodeSniffer