drupal/coder
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
dealerdirect/phpcodesniffer-composer-installer | v1.0.0 | 11.37 kB | MIT | prod dev | |
sirbrillig/phpcs-variable-analysis | v2.11.18 | - | BSD-2-Clause | prod | |
slevomat/coding-standard | 8.15.0 | - | MIT | prod | |
squizlabs/php_codesniffer | 3.10.1 | - | BSD-3-Clause | prod | |
symfony/yaml | v7.1.0 | - | MIT | prod |
The Drupal/Coder is a library specifically designed for automated Drupal code reviews and standard corrections. It works by defining rules for PHP_CodeSniffer and provides support for Drupal Coding Standards and DrupalPractice, which identifies the best practices for Drupal module development. The overall aim is to enhance code quality and ensure compliance with coding standards.
To use the Drupal/Coder package, you must first ensure that Composer is installed correctly. Then, you can globally install Coder (version 8.3.x) in your Composer directory using the composer global require drupal/coder
command. To globally access phpcs
and phpcbf
commands, you need to add the Composer bin path to your $PATH variable in ~/.profile
, ~/.bashrc
or ~/.zshrc
through the export PATH="$PATH:$HOME/.config/composer/vendor/bin"
command.
There are various command lines you can use to take advantage of what Drupal/Coder offers. For instance, you can check Drupal coding standards using the phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /file/to/drupal/example_module
command. To inspect Drupal best practices, the phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /file/to/drupal/example_module
command comes in handy. Fixing coding standards automatically is also possible through using phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /file/to/drupal/example_module
.
Also, it's worth mentioning that you can install Coder locally in your Drupal project, which can be beneficial for developer teams working concurrently. Lastly, store settings can be saved in a phpcs.xml.dist
file. The entire process provides a comprehensive solution to check coding standards and best practices in your Drupal projects effortlessly.
You can find extensive documentation related to the Drupal/Coder library on Drupal's official website, under the URL: https://www.drupal.org/node/1419980. Here, you will find a detailed explanation of all the Drupal coding standards, best practices, and how you can implement them efficiently in your projects using the Drupal/Coder package.