PHPackages                             php-collective/code-sniffer - 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. [Framework](/categories/framework)
4. /
5. php-collective/code-sniffer

ActivePhpcodesniffer-standard[Framework](/categories/framework)

php-collective/code-sniffer
===========================

PhpCollective Code Sniffer Standards

0.5.4(1mo ago)6270.2k↑63%16MITPHPPHP &gt;=8.1CI passing

Since Oct 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/php-collective/code-sniffer)[ Packagist](https://packagist.org/packages/php-collective/code-sniffer)[ Docs](https://github.com/php-collective/code-sniffer)[ RSS](/packages/php-collective-code-sniffer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (41)Used By (16)

PhpCollective Code Sniffer
==========================

[](#phpcollective-code-sniffer)

[![CI](https://github.com/php-collective/code-sniffer/workflows/CI/badge.svg)](https://github.com/php-collective/code-sniffer/actions?query=workflow%3ACI+branch%3Amaster)[![Latest Stable Version](https://camo.githubusercontent.com/d609bccb3144976b491f4dce84d1177ea7517c9a13ab77187951a69a9db48bbf/68747470733a2f2f706f7365722e707567782e6f72672f7068702d636f6c6c6563746976652f636f64652d736e69666665722f762f737461626c652e737667)](https://packagist.org/packages/php-collective/code-sniffer)[![Minimum PHP Version](https://camo.githubusercontent.com/7ddd0b2455db79dcdef99447ace66fe96bef3e86f039ffeda44df726d814e700/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d3838393242462e737667)](https://php.net/)[![PHPStan](https://camo.githubusercontent.com/f60d96f7c2579690ab6dfa8918f777fe93a02a92301c661eb38a85861a92b780/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e7376673f7374796c653d666c6174)](https://phpstan.org/)[![License](https://camo.githubusercontent.com/4209e041b4d7a876c61543216bde248a776e6c52821fe320658776a246335f03/68747470733a2f2f706f7365722e707567782e6f72672f7068702d636f6c6c6563746976652f636f64652d736e69666665722f6c6963656e73652e737667)](https://packagist.org/packages/php-collective/code-sniffer)[![Total Downloads](https://camo.githubusercontent.com/8fd7b17f143766d4ca9fab61df1e46288954b3e0c93a61dc23a98be939fc30a4/68747470733a2f2f706f7365722e707567782e6f72672f7068702d636f6c6c6563746976652f636f64652d736e69666665722f642f746f74616c2e737667)](https://packagist.org/packages/php-collective/code-sniffer)

This sniffer package follows [PSR-2](http://www.php-fig.org/psr/psr-2/) completely and ships with a lot of additional fixers on top (incl. PSR-12). Please see the PhpCollective Coding conventions for details.

[List of included sniffs.](docs/sniffs.md)

Documentation
-------------

[](#documentation)

See **[docs](docs/README.md)**.

Upstream docs: [squizlabs/PHP\_CodeSniffer/wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki)

Usage
-----

[](#usage)

### How to use in projects

[](#how-to-use-in-projects)

Make sure you include the sniffer as `require-dev` dependency:

```
composer require --dev php-collective/code-sniffer

```

Then set up a `phpcs.xml` file in your project ROOT, e.g.:

```

    src/
    tests/

```

### How to use in any project

[](#how-to-use-in-any-project)

You can manually invoke the phpcs/phpcbf commands:

```
vendor/bin/phpcs
vendor/bin/phpcbf

```

The command `phpcs` just sniffs, `phpcbf` fixes.

It is recommended to set up composer scripts to have shortcuts:

```
"scripts": {
    "cs-check": "phpcs -nps",
    "cs-fix": "phpcbf -nps"
}

```

Then you can run `composer cs-c` and `composer cs-f` and don't have to worry about the acronyms.

### Standards

[](#standards)

You can always switch the standard to the stricter one named `PhpCollectiveStrict`. It is an extension of the `PhpCollective` standard with its own (strict) sniffs added on top.

### How to include in your IDE

[](#how-to-include-in-your-ide)

E.g. for PHPStorm:

- Open Settings -&gt; Tools -&gt; External Tools
- Add a new tool named "cs-sniffer" and set Program to `$ProjectFileDir$/vendor/bin/phpcs`, Parameters to `--standard=$ProjectFileDir$/vendor/php-collective/code-sniffer/PhpCollective/ruleset.xml -p $FilePath$` and Working directory to `$ProjectFileDir$`.
- Add a new tool named "cs-fixer" and set Program to `$ProjectFileDir$/vendor/bin/phpcbf`, Parameters to `--standard=$ProjectFileDir$/vendor/php-collective/code-sniffer/PhpCollective/ruleset.xml -v $FilePath$` and Working directory to `$ProjectFileDir$`.
- Remove the "Open console" if you don't want to see any output here for the fixer.
- Now set up your hotkeys under Settings -&gt; Keymap (search for cs-sniffer and cs-fixer). E.g. `Control + Comma` for sniffing, and `Control + Dot` for fixing.

You can also set up file watchers, but here you should better only whitelist certain sniffs that only add things and don't remove anything.

### How to configure the default rule set

[](#how-to-configure-the-default-rule-set)

In order to simplify command line interface, `phpcs` allows to specify [default rule set](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-default-coding-standard) in and [standards path](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-installed-standard-paths) the following way.

Assuming the following directory structure:

```
vendor/php-collective/code-sniffer/                   # Base directory
                           |_ PhpCollective/          # Rule set name
                                      |_ ruleset.xml  # Rule set

```

The base directory and rule set can be used in configuration now.

```
vendor/bin/phpcs --config-set installed_paths vendor/php-collective/code-sniffer/
vendor/bin/phpcs --config-set default_standard PhpCollective

```

You might need to specify full directory path. Now the tools can be used without `--standard` switch.

Make sure that you include the PhpCollective core standard ruleset in your custom one, e.g.:

```

        PhpCollective Coding Standard for Project.
        Extends main PhpCollective Coding Standard.
        All sniffs in ./Sniffs/ will be auto loaded

```

If you want to use the `PhpCollectiveStrict` standard in your project, you should replace the string:

```

```

with this one:

```

```

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance90

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.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 ~25 days

Total

37

Last Release

53d ago

PHP version history (2 changes)0.1.0PHP &gt;=7.4

0.2.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39854?v=4)[Mark Scherer](/maintainers/dereuromark)[@dereuromark](https://github.com/dereuromark)

---

Top Contributors

[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (1007 commits)")[![stereomon](https://avatars.githubusercontent.com/u/1382877?v=4)](https://github.com/stereomon "stereomon (41 commits)")[![pushokwhite](https://avatars.githubusercontent.com/u/4017411?v=4)](https://github.com/pushokwhite "pushokwhite (33 commits)")[![zyuzka](https://avatars.githubusercontent.com/u/12764988?v=4)](https://github.com/zyuzka "zyuzka (11 commits)")[![serhiisikachov](https://avatars.githubusercontent.com/u/18240804?v=4)](https://github.com/serhiisikachov "serhiisikachov (7 commits)")[![ehsanmx](https://avatars.githubusercontent.com/u/7711957?v=4)](https://github.com/ehsanmx "ehsanmx (7 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (6 commits)")[![AsonUnique](https://avatars.githubusercontent.com/u/20453760?v=4)](https://github.com/AsonUnique "AsonUnique (4 commits)")[![demkos](https://avatars.githubusercontent.com/u/2093777?v=4)](https://github.com/demkos "demkos (3 commits)")[![limeeugenia](https://avatars.githubusercontent.com/u/25685017?v=4)](https://github.com/limeeugenia "limeeugenia (3 commits)")[![sylvain-spryker](https://avatars.githubusercontent.com/u/43747610?v=4)](https://github.com/sylvain-spryker "sylvain-spryker (3 commits)")[![levacic](https://avatars.githubusercontent.com/u/1636354?v=4)](https://github.com/levacic "levacic (3 commits)")[![hhebbo](https://avatars.githubusercontent.com/u/1846256?v=4)](https://github.com/hhebbo "hhebbo (2 commits)")[![asaulenko](https://avatars.githubusercontent.com/u/20285714?v=4)](https://github.com/asaulenko "asaulenko (2 commits)")[![darius-telycenas](https://avatars.githubusercontent.com/u/2518048?v=4)](https://github.com/darius-telycenas "darius-telycenas (2 commits)")[![gechetspr](https://avatars.githubusercontent.com/u/42143273?v=4)](https://github.com/gechetspr "gechetspr (2 commits)")[![gerner-spryker](https://avatars.githubusercontent.com/u/30629375?v=4)](https://github.com/gerner-spryker "gerner-spryker (2 commits)")[![lmanzke](https://avatars.githubusercontent.com/u/7486693?v=4)](https://github.com/lmanzke "lmanzke (2 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (2 commits)")[![vlunov-spryker](https://avatars.githubusercontent.com/u/17848943?v=4)](https://github.com/vlunov-spryker "vlunov-spryker (2 commits)")

---

Tags

code-stylecoding-standardshacktoberfesthacktoberfest2024phpphp-codesnifferphp-codesniffer-rulesphpcspsr-12psr-2standardsphpcsframeworkstatic analysiscodesniffer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-collective-code-sniffer/health.svg)

```
[![Health](https://phpackages.com/badges/php-collective-code-sniffer/health.svg)](https://phpackages.com/packages/php-collective-code-sniffer)
```

###  Alternatives

[spryker/code-sniffer

Spryker Code Sniffer Standards

374.1M2.3k](/packages/spryker-code-sniffer)[wp-coding-standards/wpcs

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

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

CakePHP CodeSniffer Standards

23711.0M658](/packages/cakephp-cakephp-codesniffer)[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.1M29](/packages/yoast-yoastcs)[automattic/vipwpcs

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

25510.2M145](/packages/automattic-vipwpcs)[drupal/coder

Coder is a library to review Drupal code.

3043.6M461](/packages/drupal-coder)

PHPackages © 2026

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