Skip to content

Instantly share code, notes, and snippets.

@achraf-jeday
Last active February 13, 2020 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achraf-jeday/4e6d060a7ecfe099aadce7b984f1c688 to your computer and use it in GitHub Desktop.
Save achraf-jeday/4e6d060a7ecfe099aadce7b984f1c688 to your computer and use it in GitHub Desktop.
PHP_CodeSniffer phpcs How to install PHP_CodeSniffer and to check drupal code (.module)
To install PHP_CodeSniffer and to check drupal code type the following (composer is required system-wide):
First make sure you have the composer bin dir in your PATH. The default value is ~/.composer/vendor/bin/, but you can check the value that you need to use by running:
composer global config bin-dir --absolute
echo $PATH
PATH=$PATH:~/.composer/vendor/bin/
echo $PATH
Add the following to the /home/<user>/.profile file:
export PATH="$PATH:/home/<user>/.composer/vendor/bin"
composer global require "squizlabs/php_codesniffer=*"
composer global require drupal/coder
composer global require dealerdirect/phpcodesniffer-composer-installer
phpcs -i
Above command should include DrupalPractice and Drupal in the installed coding standards list.
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md --ignore=node_modules,bower_components,vendor /home/achraf/docker/alpha-sierra-docker/web/sites/all/modules/custom/alpha_sierra_main/theme/entity_no_title.tpl.php
phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md --ignore=node_modules,bower_components,vendor /home/achraf/docker/docker_drupal/web/modules/custom/custom_opm/custom_opm.module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment