Skip to content

Instantly share code, notes, and snippets.

@Melonangie
Forked from dakala/cs.sh
Last active October 29, 2025 02:10
Show Gist options
  • Select an option

  • Save Melonangie/d87b50a811b4c5775f304e58d7c2e311 to your computer and use it in GitHub Desktop.

Select an option

Save Melonangie/d87b50a811b4c5775f304e58d7c2e311 to your computer and use it in GitHub Desktop.
Install and configure PHPCS for Drupal https://www.drupal.org/node/1587138
# Install drupal/coder
composer global require squizlabs/php_codesniffer ^3.0
composer global require drupal/coder ^8.3
composer global require dealerdirect/phpcodesniffer-composer-installer
# Register Drupal and DrupalPractice Standard with PHPCS
phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer
phpcs -i
# Colorise output
phpcs --config-set colors 1
# Add aliases
alias drupalcs="phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,js,css,info,txt,md,yml --ignore=node_modules,bower_components,vendor"
alias drupalbp="phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,js,css,info,txt,md,yml --ignore=node_modules,bower_components,vendor"
alias drupalcbf="phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,js,css,info,txt,md,yml --ignore=node_modules,bower_components,vendor"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment