Last active
February 8, 2021 00:23
-
-
Save ryanjbonnell/c0f04ded19c35333f004 to your computer and use it in GitHub Desktop.
Install PHP_CodeSniffer on Mac OS X for Drupal Coding Standards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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