PHP Code Sniffer
With phpcs you can check if your code matches the Joomla Coding Standards
Installation
With Pear (not for El Capitan)
The current Joomla! code style rules still need version 1.5.6 of phpcs. Install it using pear with the following command:
pear install PHP_CodeSniffer-1.5.6
After that we have to install the Joomla code style rules:
git clone https://github.com/joomla/coding-standards.git `pear config-get php_dir`/PHP/CodeSniffer/Standards/Joomla
For more details see also the Joomla Coding Standards Github repository
Composer
First install composer (See chapter Composer)
composer global require squizlabs/php_codesniffer=1.5.6
If you added the composer binary directory to your $PATH (in the .zshrc or .basrc file) you can now use phpcs as normal command on the command line.
After that download and add the Joomla! code style rules:
git clone https://github.com/joomla/coding-standards.git \
$HOME/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Joomla
Manual
You can also install it with curl
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
php phpcs.phar -h
Usage
You can use phpcs as a standalone program, but most times you just want to integrate it into PHPStorm.
phpcs --standard=/usr/lib/php/pear/PHP/CodeSniffer/Standards/Joomla path/to/code.php