Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save apotashov/fbd07e16e665a3a6ded0b8e477f109fc to your computer and use it in GitHub Desktop.

Select an option

Save apotashov/fbd07e16e665a3a6ded0b8e477f109fc to your computer and use it in GitHub Desktop.
MacOS: Install PHP_CodeSniffer on Mac OS X for Drupal Coding Standards
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment