Install PHP Code Sniffer (phpcs)

PHP CodeSniffer, aka phpcs, helps you in detecting violations in your PHP code. Violations can be:

  • opening curly brackets in the wrong place (on a new line, or vice versa)
  • indentation
  • use of upper- or lowercase variable/function/method/class names
  • missing phpdoc blocks for files, classes or functions
  • your own coding standards
  • etc.

Before installing PHP CodeSniffer with PEAR, you actually need to install PEAR.

Installing PHP CodeSniffer is as simple as:

$ sudo pear install PHP_CodeSniffer

Check out the manual for more information:

What now?

  • Use PHP Code Sniffer with PHPStorm IDE
  • Use PHP Code Sniffer with your Continuous Integration like Jenkins

Leave a Reply

Your email address will not be published. Required fields are marked *