Skip to main content
Home
Techies Briefcase
~ by Hari Venu

Main navigation

  • Home
  • Tools
    • Placeholder Image
    • JSON Diff
    • QR Code Generator
    • Random String Generator
    • HTML to PDF Generator
  • About me
  • Photos
  • Search

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

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

Online Resume : Online Resume

Work !!!

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

Powered by Drupal & Maintained by Hari