PHP CodeSniffer – Coding Standard Tool

Install PHP-Coding-Standards

> pear install PHP_CodeSniffer-2.8.1

Install WordPress-Coding-Standards

> cd /var/www/html
> git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
> phpcs –config-set installed_paths /var/www/html/wpcs

Install Codeigniter-Coding-Standards

> git clone https://github.com/thomas-ernest/CodeIgniter-for-PHP_CodeSniffer.git
> ant

or

> ant -Dphpcs.dir=”/usr/share/php/PHP/CodeSniffer”

Check Supported standards

> phpcs -i

Uninstall PHP-Coding-Standards

> pear uninstall PHP_CodeSniffer-2.8.1

Check Errors and Warnings

> phpcs file.php

Autofix Errors

> phpcbf file.php