# Install PEAR (PHP Extension and Application Repository) $ sudo php /usr/lib/php/install-pear-nozlib.phar $ sudo pear upgrade-all $ sudo pear install --alldeps PHP_CodeSniffer # Add PEAR to `php.ini` Include Path $ nano /etc/php.ini ;include_path = ".:/php/includes" include_path = ".:/php/includes:/usr/lib/php/pear" # Download Drupal Coder Module $ cd /usr/local/src $ curl -OL http://ftp.drupal.org/files/projects/coder-7.x-2.x-dev.tar.gz $ tar zxf coder-7.x-2.x-dev.tar.gz # Add Drupal Coding Standards to PHP_CodeSniffer $ sudo cp -r /usr/local/src/coder/coder_sniffer/Drupal /usr/lib/php/pear/PHP/CodeSniffer/Standard # Verify PHP_CodeSniffer's Installed Coding Standards $ which phpcs $ /usr/bin/phpcs -i # PHP_CodeSniffer Example Usage: Single File $ phpcs --standard=/usr/lib/php/pear/PHP/CodeSniffer/Standard/Drupal ~/example.dev/garland/template.php $ phpcs --report=full --standard=Drupal ~/Sites/example.dev/themes/garland/template.php # PHP_CodeSniffer Example Usage: Entire Directory $ phpcs --report=full --standard=Drupal --extensions="php,module,inc,install,test,profile,theme" ~/Sites/example.dev/themes/garland