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

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