Skip to main content
Home
Techies Briefcase
~ by Hari Venu

Main navigation

  • Home
  • About me
  • Photos
  • My Bookmarks

Breadcrumb

  1. Home
  2. Drupal Coder and Php Codesniffer On Your Drupal Project

Drupal coder and php codesniffer on your Drupal project

By hari, 1 January, 2023

Drupal coder and codesniffer will help you to check the coding standards in your custom code. Here is the steps for install and run the coding violation test on your command line.

Steps

  1. Install the Coder module as a dev requirement, along with the Composer installer for PHP_CodeSniffer coding standards:

    $ composer require --dev drupal/coder dealerdirect/phpcodesniffer-composer-installer
  2. Verify the installation is working:

    $ ./vendor/bin/phpcs -i

    (should list Drupal and DrupalPractice in its output)

  3. Once it's working, you can start using phpcs which was installed into the vendor/bin directory:

    
    ./vendor/bin/phpcs \
      --standard="Drupal,DrupalPractice" -n \
      --extensions="php,module,inc,install,test,profile,theme,css,txt,md,yml" \
      web/themes/harivenu \
      web/modules/custom
    

Additional information

  • List enabled Drupal coding standards rules

    
    $ phpcs --standard="Drupal" -e
    
  • Check only one rule

    
    $ phpcs --standard="Drupal" --extensions="php,module,inc,install,test,profile,theme,css,txt,md,yml" --sniffs=Drupal.Classes.UnusedUseStatement web/modules/custom
    
  • Check Drupal best practices

    
    $ phpcs --standard="DrupalPractice" --extensions="php,module,inc,install,test,profile,theme,css,txt,md,yml"  web/modules/custom
    
  • Automatically fix coding standards

    
    $ phpcbf --standard="Drupal" --extensions="php,module,inc,install,test,profile,theme,css,txt,md,yml"  web/modules/custom
    
Reference
  • https://www.drupal.org/docs/contributed-modules/code-review-module/php-codesniffer-command-line-usage

Tags

  • Drupal
  • Coder
  • Codesniffer
  • phpcs
  • phpcbf
 

Topics

  • Composer
  • Commad Line Tools
  • JavaScript
  • Drupal
  • Solar Panel
  • Permission
  • Libraries
  • MySQL
  • Commad Line
  • RSA
  • VSCode
  • Windows
  • Entity Query API
  • Ubuntu
  • Bash Script
  • Drush
  • Bower
  • Errors
  • Workflow
  • File API
  • Docker
  • Linux
  • Lando
  • Articles
  • Views
  • Nginx
  • Twig
  • Multilingual
  • OOPs
  • Coder
  • Solar Power
  • PHP
  • Field API
  • Android
  • Cache
  • Webform
  • jQuery
  • phpcbf
  • Ajax API
  • Distribution
  • Drupal Behavior
  • Learning
  • kali
  • professional development
  • Neuron AI
  • Jellyfin
  • SSH
  • URL
  • Macbook
  • WSL2
  • Drupal AI
  • NPM
  • Git
  • Form API
  • phpcs
  • Drupal Console
  • Codesniffer
  • Moderation
  • PHPSeclib
  • Taxonomy
  • Mac OS
RSS Feed

Who am I !!!

Hari Venu V
harivenu.v1992@gmail.com
Mobile : +91 9895164181
Whatsapp : +91 9895164181
Linkedin
Drupal.org
Github

Document
Resume.pdf (114.38 KB)

Work !!!

Fulltime Developer @ QED42
hari.venu@qed42.com
Linkedin

Powered by Drupal & Maintained by Hari