Setting up CodeSniffer to validate Joomla! coding standards on Ubuntu

Last days some pull requests injected some non-standard code into the Joomla! master branch. This is a great moment to remember how to setup PHP CodeSniffer to ensure that our code is standard compliant.

Joomla! has a repository on Github with its coding standards. The README contains all the required info to setup phpcs:

1Install CodeSniffer

The CodeSniffer integrated Ubuntu is usually too old to setup it to work with Joomla! Standards that require version 1.3+. So we better install the latest CodeSniffer with PEAR:

sudo pear install PHP_CodeSniffer

2Install Joomla! standards

We can clone directly the Joomla! standard Github repo into the CodeSniffer standards folder with the command: