PHPackages                             acquia/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. [Testing &amp; Quality](/categories/testing)
4. /
5. acquia/coding-standards

ActivePhpcodesniffer-standard[Testing &amp; Quality](/categories/testing)

acquia/coding-standards
=======================

PHP\_CodeSniffer rules (sniffs) for Acquia coding standards

v3.0.3(6mo ago)214.8M—3.4%15[5 issues](https://github.com/acquia/coding-standards-php/issues)20GPL-2.0-or-laterCI passing

Since Jun 18Pushed 1mo ago10 watchersCompare

[ Source](https://github.com/acquia/coding-standards-php)[ Packagist](https://packagist.org/packages/acquia/coding-standards)[ RSS](/packages/acquia-coding-standards/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (23)Used By (20)

Acquia Coding Standards for PHP
===============================

[](#acquia-coding-standards-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/dda3067ecbc59a54c18ec9084b96469e8408d0a8ab4a1975f6583c8a61a6abde/68747470733a2f2f706f7365722e707567782e6f72672f6163717569612f636f64696e672d7374616e64617264732f762f737461626c65)](https://packagist.org/packages/acquia/coding-standards)[![Total Downloads](https://camo.githubusercontent.com/4fd245ade3c3775ce7d2aa90dedc1178fea9feefb1c7c7fd4374b439c82d1439/68747470733a2f2f706f7365722e707567782e6f72672f6163717569612f636f64696e672d7374616e64617264732f646f776e6c6f616473)](https://packagist.org/packages/acquia/coding-standards)[![Latest Unstable Version](https://camo.githubusercontent.com/d624971f42e1d8edf9aa10ae17a8dfadfe5f9703cd91921625731573956c3780/68747470733a2f2f706f7365722e707567782e6f72672f6163717569612f636f64696e672d7374616e64617264732f762f756e737461626c65)](https://packagist.org/packages/acquia/coding-standards)[![License](https://camo.githubusercontent.com/9bfa564cfc5b1757a9b69ddc7f99ba01057bc791dcb588e1ccf144b901b004e3/68747470733a2f2f706f7365722e707567782e6f72672f6163717569612f636f64696e672d7374616e64617264732f6c6963656e7365)](https://packagist.org/packages/acquia/coding-standards)[![Tests](https://github.com/acquia/coding-standards-php/actions/workflows/orca.yml/badge.svg)](https://github.com/acquia/coding-standards-php/actions/workflows/orca.yml)

Acquia Coding Standards for PHP is a collection of [PHP\_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) rules (sniffs) for Acquia coding standards for PHP projects, including Drupal extensions.

Rules
-----

[](#rules)

Acquia Coding Standards for PHP includes a selection of sniffs from the following rulesets:

- [Drupal Code Sniffer](https://packagist.org/packages/drupal/coder) encapsulates [Drupal coding standards](https://www.drupal.org/coding-standards) and best practices for module development.
- [PHP\_CodeSniffer](https://packagist.org/packages/squizlabs/php_codesniffer) itself contains several broadly applicable rulesets.
- [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) checks for PHP cross-version compatibility with all supported language versions.
- [Slevomat Coding Standard](https://github.com/slevomat/coding-standard) provides functional (safety and behavior), cleaning (dead code), and formatting (consistent look) sniffs.

Rulesets
--------

[](#rulesets)

Rules are split into rulesets according to the project *framework* and *audience*:

- Projects targeting the Drupal community, e.g., Drupal modules, should adopt a *Drupal* ruleset. All others should adopt a (more generalized) *PHP* ruleset.
- Public projects, e.g., open-source Drupal modules, should adopt a *non-strict* ruleset to facilitate external collaboration. All others should adopt a more opinionated *internal* ruleset.

There are four permutations of these guidelines, leading to four rulesets to choose from:

- [AcquiaDrupalMinimal](src/Standards/AcquiaDrupalMinimal/ruleset.xml) is based on the Drupal coding standard and is intended for use on all public Drupal projects.
- [AcquiaDrupalStrict](src/Standards/AcquiaDrupalStrict/ruleset.xml) is based on AcquiaDrupal and adds the more opinionated DrupalPractice standard. It is intended for use on all internal Drupal projects.
- [AcquiaPHPMinimal](src/Standards/AcquiaPHPMinimal/ruleset.xml) is based on PSR-12 and is intended for use on all public non-Drupal projects.
- [AcquiaPHPStrict](src/Standards/AcquiaPHPStrict/ruleset.xml) is based on AcquiaPHP and adds additional, more opinionated standards. It is intended for use on all internal, non-Drupal projects.

Installation &amp; usage
------------------------

[](#installation--usage)

1. Add Acquia Coding Standards for PHP to your project via Composer:

    ```
    composer require --dev acquia/coding-standards
    ```
2. Inform PHP CodeSniffer of the location of the standard and its dependencies:

    - It is strongly recommended that you use a Composer plugin to handle this for you, e.g., [`DealerDirect/phpcodesniffer-composer-installer`](https://github.com/DealerDirect/phpcodesniffer-composer-installer):

        ```
        composer config extra.phpcodesniffer-search-depth 4
        composer require --dev dealerdirect/phpcodesniffer-composer-installer
        ```
    - Alternatively, add a script to your `composer.json` to handle it:

        ```
        {
            "scripts": {
                "post-install-cmd": "@install-coding-standards",
                "post-update-cmd" : "@install-coding-standards",
                "install-coding-standards": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/acquia/coding-standards/src/Standards,vendor/drupal/coder/coder_sniffer,vendor/phpcompatibility/php-compatibility,vendor/slevomat/coding-standard"
            }
        }
        ```
3. Check code for standards compliance:

    ```
    ./vendor/bin/phpcs --standard=AcquiaDrupalStrict --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml path/to/code
    ```

    Automatically fix any standards violations possible:

    ```
    ./vendor/bin/phpcbf --standard=AcquiaDrupalStrict --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml path/to/code
    ```

    The `--extensions` argument must match the chosen code standard. For AcquiaPHP, use `--extensions=php,inc,test,css,txt,md,yml`.
4. Optionally create a [default configuration file](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file) for your project so you don't have to provide the command-line arguments every time (i.e., below). Here's a working example: [`example/phpcs.xml.dist`](example/phpcs.xml.dist).

    ```
    ./vendor/bin/phpcs
    ```

    Modify `phpcs.xml.dist` to suit your project, especially to set the preferred code standard and matching extensions.
5. Optionally add code checking to your [Git pre-commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to prevent committing code with violations. Since client-side Git hooks are not copied when a repository is cloned, you might like to use an automated solution like [`BrainMaestro/composer-git-hooks`](https://packagist.org/packages/BrainMaestro/composer-git-hooks) to manage them, for example: [`example/composer.json`](example/composer.json).
6. Optionally [configure PHP Code Sniffer integration in PhpStorm](https://www.jetbrains.com/help/phpstorm/using-php-code-sniffer.html) or your IDE or code editor of choice. You can import [`example/PhpStormInspections.xml`](example/PhpStormInspections.xml) to set up default integration for new projects. When you open or create a new project for the first time, PhpStorm should automatically detect and set up PHPCS inspections based on these defaults. You will just need to uncheck the “installed standards paths” in the inspection settings for your project so that PhpStorm can find the Acquia Coding Standards.

Contribution
------------

[](#contribution)

Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).

License
-------

[](#license)

Copyright (C) 2019 Acquia, Inc.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance74

Regular maintenance activity

Popularity54

Moderate usage in the ecosystem

Community38

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 51.7% 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 ~116 days

Recently: every ~242 days

Total

21

Last Release

200d ago

Major Versions

v0.9.0 → v1.0.02022-05-12

v1.1.0 → v2.0.02023-03-06

v2.0.0 → v3.0.02024-07-10

### Community

Maintainers

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

![](https://avatars.githubusercontent.com/u/514789?v=4)[Acquia](/maintainers/acquia)[@acquia](https://github.com/acquia)

![](https://avatars.githubusercontent.com/u/1984514?v=4)[Dane Powell](/maintainers/danepowell)[@danepowell](https://github.com/danepowell)

![](https://www.gravatar.com/avatar/0e8969114e0f3bdd130d021357e5003be19cb0517fa3507eb6c429b020f06f16?d=identicon)[jfarrell](/maintainers/jfarrell)

---

Top Contributors

[![TravisCarden](https://avatars.githubusercontent.com/u/959246?v=4)](https://github.com/TravisCarden "TravisCarden (76 commits)")[![danepowell](https://avatars.githubusercontent.com/u/1984514?v=4)](https://github.com/danepowell "danepowell (57 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![gabesullice](https://avatars.githubusercontent.com/u/4500265?v=4)](https://github.com/gabesullice "gabesullice (1 commits)")[![GaryJones](https://avatars.githubusercontent.com/u/88371?v=4)](https://github.com/GaryJones "GaryJones (1 commits)")[![joshirohit100](https://avatars.githubusercontent.com/u/1336423?v=4)](https://github.com/joshirohit100 "joshirohit100 (1 commits)")[![fiasco](https://avatars.githubusercontent.com/u/108160?v=4)](https://github.com/fiasco "fiasco (1 commits)")[![Raksha-Bharuka](https://avatars.githubusercontent.com/u/43320617?v=4)](https://github.com/Raksha-Bharuka "Raksha-Bharuka (1 commits)")[![rodrigoprimo](https://avatars.githubusercontent.com/u/77215?v=4)](https://github.com/rodrigoprimo "rodrigoprimo (1 commits)")[![secretsayan](https://avatars.githubusercontent.com/u/9529657?v=4)](https://github.com/secretsayan "secretsayan (1 commits)")[![narendradesai](https://avatars.githubusercontent.com/u/25113577?v=4)](https://github.com/narendradesai "narendradesai (1 commits)")

---

Tags

standardsphpcsstatic analysisdrupal

### Embed Badge

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

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

###  Alternatives

[wp-coding-standards/wpcs

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

2.8k42.5M1.6k](/packages/wp-coding-standards-wpcs)[phpcompatibility/phpcompatibility-wp

A ruleset for PHP\_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.

22130.6M587](/packages/phpcompatibility-phpcompatibility-wp)[phpcsstandards/phpcsextra

A collection of sniffs and standards for use with PHP\_CodeSniffer.

10324.3M44](/packages/phpcsstandards-phpcsextra)[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)

PHPackages © 2026

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