drupol/drupal-conventions

Drupal conventions for coding.


README

Latest Stable Version Stars Total Downloads Build Status License

Drupal conventions

This tool will check your code against Drupal's coding standard.

It's based on GrumPHP and comes with a default configuration tailored for Drupal development.

The following checks are triggered:

Drupal 7 and 8 are supported.

Installation

composer require drupol/drupal-conventions --dev

If you're not using GrumPHP

Manually add to your composer.json file:

Drupal 8

    "extra": {
        "grumphp": {
            "config-default-path": "vendor/drupol/drupal-conventions/config/drupal8/grumphp.yml"
        }
    }

Drupal 7

    "extra": {
        "grumphp": {
            "config-default-path": "vendor/drupol/drupal-conventions/config/drupal7/grumphp.yml"
        }
    }

The default Drupal 7 configuration assume that you're using PHP >= 7, use this configuration for Drupal 7 & PHP 5.6.

    "extra": {
        "grumphp": {
            "config-default-path": "vendor/drupol/drupal-conventions/config/drupal7/php5.6/grumphp.yml"
        }
    }

If you're using GrumPHP already

Edit the file grumphp.yml.dist or grumphp.yml and add on the top it:

Drupal 8

imports:
  - { resource: vendor/drupol/drupal-conventions/config/drupal8/grumphp.yml }

Drupal 7

imports:
  - { resource: vendor/drupol/drupal-conventions/config/drupal7/grumphp.yml }

To add an extra Grumphp task:

imports:
  - { resource: vendor/drupol/drupal-conventions/config/drupal7/grumphp.yml }

parameters:
  extensions:
    - drupol\DrupalConventions\GrumphpTasksExtension
  extra_tasks:
    phpunit:
      always_execute: false

In conjunction with extra_tasks, use skip_tasks to exclude default tasks if needed.

Contributing

Feel free to contribute to this library by sending Github pull requests. I'm quite reactive :-)