PHPackages                             drupal-standards/drupal-coding-standards - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. drupal-standards/drupal-coding-standards

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

drupal-standards/drupal-coding-standards
========================================

Creates a pre-push git hook that checks the Drupal coding standards.

8.0.x-dev(10y ago)41.1kPHP

Since Nov 17Pushed 10y ago2 watchersCompare

[ Source](https://github.com/danielpopdan/drupal-coding-standards)[ Packagist](https://packagist.org/packages/drupal-standards/drupal-coding-standards)[ RSS](/packages/drupal-standards-drupal-coding-standards/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

About
=====

[](#about)

This is a git pre-push hook intended to help Drupal developers to keep the code base clean by performing a scan with Drupal Coder whenever new code is pushed to the repository. When any coding standards violations are present the push is rejected, allowing the developer to fix the code before making it public.

To increase performance only the changed files are checked when new code is pushed to repository. Note that the full file will be checked, so if you didn't use this library from the beginning you can get coding violations from the past.

With this library you can make the code review phase more quickly, letting the reviewers just to concentrate on the logic of the project. If you don't want to use this anymore, you can easily delete the `pre-push` hook from `.git/hooks/`directory. If you notice any issue, please let us know on [GitHub issue page](https://github.com/danielpopdan/drupal-coding-standards/issues)of the project.

Installation
============

[](#installation)

Add Drupal Coding Standards to your composer.json:

*Option 1:*

```
composer require drupal-standards/drupal-coding-standards:master-dev

```

*Option 2:*

**`composer.json`**

```
{
  "require": {
    "drupal-standards/drupal-coding-standards": "master-dev"
  }
}

```

A post install scripts is needed to symlink the pre-push file of the library with the git pre-push file and to register the Drupal Coding Standards. Because of security issues, composer doesn't execute post install scripts of dependencies, so you will have to add this script to your composer.json. Please add the [post install script](https://github.com/danielpopdan/drupal-coding-standards/blob/master/scripts/composer/post-install.sh)to scripts/composer directory of your Drupal project root, in the post-install.sh file.

```
#!/bin/sh

# Symlink the git pre-push hook to its destination.
if [ ! -h ".git/hooks/pre-push" ] ; then
  ln -s "../../vendor/drupal-standards/drupal-coding-standards/pre-push" ".git/hooks/pre-push"
  vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer
fi

```

After that you will have to make this script file executable:

```
chmod u+x scripts/composer/post-install.sh

```

Please add the script to your composer.json file:

```
"scripts": {
    "post-install-cmd": "scripts/composer/post-install.sh"
}

```

Now you can run composer install:

```
composer install

```

Adding the Rule Set
===================

[](#adding-the-rule-set)

The final step is to add the [Drupal Code Sniffer Ruleset](https://github.com/danielpopdan/drupal-coding-standards/blob/master/drupalcs.xml), because you probably have some files you don't want to be parsed.

The rule set contains two very important tags, and .

With this tag you can exclude any file you want, by default all core files and features generated files are excluded, but you can add other files too, like a custom setting php, or you can totally exclude all files of a type, like CSS, because your css is generated by SAS.

For you can pass a name and a value which will be passed to Code Sniffer, for example:

```

```

That will be passed as `--standard=Drupal`.

Every time you make a composer update this file will be overridden, so the best way to keep your configuration is to copy that file to your root directory of the Drupal project. The pre-push hook will check the file from your root every time.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3882d ago

Major Versions

7.0.x-dev → 8.0.x-dev2015-11-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/c597a9bbd0da9b69b82db52a521c55f6b3adfbbe0cbca58d4e4f845428925526?d=identicon)[danielpopdan](/maintainers/danielpopdan)

---

Top Contributors

[![danielpopdan](https://avatars.githubusercontent.com/u/9623300?v=4)](https://github.com/danielpopdan "danielpopdan (1 commits)")

---

Tags

standardsdrupalcoding

### Embed Badge

![Health badge](/badges/drupal-standards-drupal-coding-standards/health.svg)

```
[![Health](https://phpackages.com/badges/drupal-standards-drupal-coding-standards/health.svg)](https://phpackages.com/packages/drupal-standards-drupal-coding-standards)
```

###  Alternatives

[symfony/translation-contracts

Generic abstractions related to translation

2.6k747.7M667](/packages/symfony-translation-contracts)[symfony/cache-contracts

Generic abstractions related to caching

2.4k332.6M316](/packages/symfony-cache-contracts)[symfony/http-client-contracts

Generic abstractions related to HTTP clients

2.0k428.1M430](/packages/symfony-http-client-contracts)[symfony/contracts

A set of abstractions extracted out of the Symfony components

3.9k65.9M138](/packages/symfony-contracts)[phpcompatibility/php-compatibility

A set of sniffs for PHP\_CodeSniffer that checks for PHP cross-version compatibility.

2.3k81.1M1.6k](/packages/phpcompatibility-php-compatibility)[automattic/vipwpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions

25811.4M200](/packages/automattic-vipwpcs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
