PHPackages                             drupal/coder - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. drupal/coder

ActivePhpcodesniffer-standard[Validation &amp; Sanitization](/categories/validation)

drupal/coder
============

Coder is a library to review Drupal code.

9.0.0(2mo ago)3043.6M—4.6%52[5 PRs](https://github.com/pfrenssen/coder/pulls)20GPL-2.0-or-laterPHPPHP &gt;=7.4CI failing

Since Feb 23Pushed 2w ago4 watchersCompare

[ Source](https://github.com/pfrenssen/coder)[ Packagist](https://packagist.org/packages/drupal/coder)[ Docs](https://www.drupal.org/project/coder)[ RSS](/packages/drupal-coder/feed)WikiDiscussions 8.3.x Synced 1mo ago

READMEChangelogDependencies (14)Versions (62)Used By (20)

Coder
=====

[](#coder)

[![Automated tests](https://github.com/pfrenssen/coder/workflows/Tests/badge.svg)](https://github.com/pfrenssen/coder/actions)

Coder is a library for automated Drupal code reviews and coding standard fixes. It defines rules for [PHP\_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/)

Built-in support for:

- "Drupal": Coding Standards
- "DrupalPractice": Best practices for Drupal module development

Online documentation:

Note that Javascript support has been removed. To check and fix Javascript files please use [ESLint](http://eslint.org/) and see the [Drupal ESLint](https://www.drupal.org/node/1955232) documentation.

Local installation in your Drupal project
-----------------------------------------

[](#local-installation-in-your-drupal-project)

For collaborating developer teams it makes sense to lock a Coder version with your other development dependencies locally. In your project where you have your composer.json file execute this:

```
composer require --dev drupal/coder

```

Then you can run Coder on your custom module code like this:

```
./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml web/modules/custom

```

To simplify execution it is highly recommended to use a settings file, see below.

Usage
-----

[](#usage)

Check Drupal coding standards

```
./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml web/modules/custom

```

Check Drupal best practices

```
./vendor/bin/phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml web/modules/custom

```

Automatically fix coding standards

```
./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml web/modules/custom

```

Store settings in a phpcs.xml.dist file
---------------------------------------

[](#store-settings-in-a-phpcsxmldist-file)

In order to save and commit your PHPCS settings to Git you can use a phpcs.xml.dist file in your project like this:

```

  PHP CodeSniffer configuration for example development.

  web/modules/custom

```

Then you can invoke phpcs without any options and it will read phpcs.xml.dist from the current directory. This can also be useful for Continuous Integration setups. Example:

```
./vendor/bin/phpcs -p

```

Working with Editors
--------------------

[](#working-with-editors)

Drupal Code Sniffer can be used with various editors.

Editors:

- [Atom](https://www.drupal.org/node/1419996)
- [Eclipse](https://www.drupal.org/node/1420004)
- [Komodo](https://www.drupal.org/node/1419996)
- [Netbeans](https://www.drupal.org/node/1420008)
- [PhpStorm](https://www.jetbrains.com/help/phpstorm/php-code-sniffer.html)
- [Sublime Text](https://www.drupal.org/node/1419996)
- [Vim](https://www.drupal.org/node/1419996)
- [Visual Studio Code (VSCode)](https://www.drupal.org/node/1419996)

Automated Testing (PHPUnit + PHPCS + PHPStan)
---------------------------------------------

[](#automated-testing-phpunit--phpcs--phpstan)

Coder Sniffer comes with a PHPUnit test suite to make sure the sniffs work correctly. Use Composer to install the dependencies:

```
composer install

```

Then execute the tests:

```
./vendor/bin/phpunit

```

Then execute the coding standards checker on Coder itself:

```
./vendor/bin/phpcs

```

Then execute static analysis:

```
./vendor/bin/phpstan

```

Contributing
------------

[](#contributing)

Please [create an issue fork and merge request on drupal.org](https://www.drupal.org/docs/develop/git/using-gitlab-to-contribute-to-drupal).

Thank you!

Maintainers
-----------

[](#maintainers)

- Pieter Frenssen,
- Michael Welford,
- Klaus Purer,

Credits
-------

[](#credits)

Juliette Reinders Folmer and Greg Sherwood, many sniffs are modified copies of their original work on [PHPCS](https://github.com/PHPCSStandards/PHP_CodeSniffer/).

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance92

Actively maintained with recent releases

Popularity63

Solid adoption and visibility

Community53

Growing community involvement

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 63.6% 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 ~75 days

Recently: every ~27 days

Total

59

Last Release

66d ago

Major Versions

7.2.3 → 8.2.0-rc12014-12-06

7.2.4 → 8.2.12015-03-06

7.2.5 → 8.2.32015-06-26

8.3.31 → 9.0.0-alpha12025-10-26

8.3.x-dev → 9.0.0-beta12025-12-07

PHP version history (7 changes)7.2.2PHP &gt;=5.2.0

8.2.6PHP &gt;=5.4.0

8.3.2PHP &gt;=5.5.9

8.3.8PHP &gt;=7.0.8

8.3.14PHP &gt;=7.1

8.3.19PHP &gt;=7.2

9.0.0-alpha1PHP &gt;=7.4

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/2e8002bbd41b86bc1aa39bfd23074f88c0816d46e511fefa26701d176286d396?d=identicon)[pfrenssen](/maintainers/pfrenssen)

![](https://www.gravatar.com/avatar/57428d8f8df89bf80d218b9b6900f6344ca67fea7bb132433f06e1212fc27dea?d=identicon)[Drupal](/maintainers/Drupal)

![](https://avatars.githubusercontent.com/u/27288432?v=4)[Drupal Infrastructure](/maintainers/Drupal-Infrastructure)[@Drupal-Infrastructure](https://github.com/Drupal-Infrastructure)

![](https://www.gravatar.com/avatar/50d6cba2fbb81463008ad8c782c43fab7689980c3447d63ce2b7fa1d7191e0c1?d=identicon)[Arkener](/maintainers/Arkener)

---

Top Contributors

[![klausi](https://avatars.githubusercontent.com/u/213229?v=4)](https://github.com/klausi "klausi (870 commits)")[![douggreen](https://avatars.githubusercontent.com/u/1244341?v=4)](https://github.com/douggreen "douggreen (282 commits)")[![solotandem](https://avatars.githubusercontent.com/u/314718?v=4)](https://github.com/solotandem "solotandem (41 commits)")[![arkener](https://avatars.githubusercontent.com/u/16407031?v=4)](https://github.com/arkener "arkener (28 commits)")[![snpower](https://avatars.githubusercontent.com/u/1731285?v=4)](https://github.com/snpower "snpower (26 commits)")[![pfrenssen](https://avatars.githubusercontent.com/u/442924?v=4)](https://github.com/pfrenssen "pfrenssen (21 commits)")[![sun](https://avatars.githubusercontent.com/u/41992?v=4)](https://github.com/sun "sun (19 commits)")[![jonathan1055](https://avatars.githubusercontent.com/u/19403539?v=4)](https://github.com/jonathan1055 "jonathan1055 (18 commits)")[![das-peter](https://avatars.githubusercontent.com/u/177531?v=4)](https://github.com/das-peter "das-peter (16 commits)")[![ericduran](https://avatars.githubusercontent.com/u/118016?v=4)](https://github.com/ericduran "ericduran (6 commits)")[![eiriksm](https://avatars.githubusercontent.com/u/865153?v=4)](https://github.com/eiriksm "eiriksm (5 commits)")[![alexpott](https://avatars.githubusercontent.com/u/769634?v=4)](https://github.com/alexpott "alexpott (4 commits)")[![Boegie](https://avatars.githubusercontent.com/u/18569707?v=4)](https://github.com/Boegie "Boegie (4 commits)")[![christopher-hopper](https://avatars.githubusercontent.com/u/452515?v=4)](https://github.com/christopher-hopper "christopher-hopper (3 commits)")[![LOBsTerr](https://avatars.githubusercontent.com/u/537500?v=4)](https://github.com/LOBsTerr "LOBsTerr (3 commits)")[![mfernea](https://avatars.githubusercontent.com/u/146230?v=4)](https://github.com/mfernea "mfernea (3 commits)")[![adamzimmermann](https://avatars.githubusercontent.com/u/1349906?v=4)](https://github.com/adamzimmermann "adamzimmermann (2 commits)")[![cburschka](https://avatars.githubusercontent.com/u/1448001?v=4)](https://github.com/cburschka "cburschka (2 commits)")[![chipway](https://avatars.githubusercontent.com/u/1422820?v=4)](https://github.com/chipway "chipway (2 commits)")[![claudiu-cristea](https://avatars.githubusercontent.com/u/473868?v=4)](https://github.com/claudiu-cristea "claudiu-cristea (2 commits)")

---

Tags

standardsphpcscode review

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.1M29](/packages/yoast-yoastcs)[mayflower/mo4-coding-standard

PHP CodeSniffer ruleset implementing the MO4 coding standards extending the Symfony coding standards.

17508.3k5](/packages/mayflower-mo4-coding-standard)[ec-europa/qa-automation

Extra php codesniffs for QualityAssurance.

10290.4k3](/packages/ec-europa-qa-automation)[orisai/coding-standard

Strict PHP coding standard

19193.5k62](/packages/orisai-coding-standard)

PHPackages © 2026

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