PHPackages                             phpcsstandards/php\_codesniffer - 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. [CLI &amp; Console](/categories/cli)
4. /
5. phpcsstandards/php\_codesniffer

Abandoned → [squizlabs/php\_codesniffer](/?search=squizlabs%2Fphp_codesniffer)Library[CLI &amp; Console](/categories/cli)

phpcsstandards/php\_codesniffer
===============================

PHP\_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.

4.0.1(6mo ago)1.5k292.6k↓23.8%95[135 issues](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues)[21 PRs](https://github.com/PHPCSStandards/PHP_CodeSniffer/pulls)5BSD-3-ClausePHPPHP &gt;=7.2.0CI passing

Since Nov 9Pushed 1mo ago18 watchersCompare

[ Source](https://github.com/PHPCSStandards/PHP_CodeSniffer)[ Packagist](https://packagist.org/packages/phpcsstandards/php_codesniffer)[ Docs](https://github.com/PHPCSStandards/PHP_CodeSniffer)[ GitHub Sponsors](https://github.com/PHPCSStandards)[ GitHub Sponsors](https://github.com/jrfnl)[ RSS](/packages/phpcsstandards-php-codesniffer/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (121)Used By (5)

PHP\_CodeSniffer
================

[](#php_codesniffer)

[![Latest Stable Version](https://camo.githubusercontent.com/6ce934253ef35d2426bb4ac9663b6e0b289e5a3e3cc6abfa12f8eb153d7e463c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f50485043535374616e64617264732f5048505f436f6465536e69666665723f6c6162656c3d537461626c65)](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases)[![Validate](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml/badge.svg?branch=4.x)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml)[![Test](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml/badge.svg?branch=4.x)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml)[![Coverage Status](https://camo.githubusercontent.com/94332d51f0108f969121833b8443f66107c5b6ffa9530acd3b48fabc57d84474/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f50485043535374616e64617264732f5048505f436f6465536e69666665722f62616467652e7376673f6272616e63683d342e78)](https://coveralls.io/github/PHPCSStandards/PHP_CodeSniffer?branch=4.x)[![License](https://camo.githubusercontent.com/46b1e90a280e378106cd35c38c7c847a96e8d1defd053124755961f2fd82ec40/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f50485043535374616e64617264732f5048505f436f6465536e6966666572)](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/HEAD/licence.txt)

[![Minimum PHP Version](https://camo.githubusercontent.com/b9e9e5bb5e554172ede0812b165fcc3efc824d2a3591ad20aa26e4119d9ebe76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f737175697a6c6162732f7068705f636f6465736e69666665722f7068702e737667)](https://camo.githubusercontent.com/b9e9e5bb5e554172ede0812b165fcc3efc824d2a3591ad20aa26e4119d9ebe76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f737175697a6c6162732f7068705f636f6465736e69666665722f7068702e737667)[![Tested on PHP 7.2 to 8.5](https://camo.githubusercontent.com/7216dbe541316bd92bbf69f27c349e741a2f299b9c7241224a3d868de59ec5c0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7465737465642532306f6e2d504850253230372e32253230253743253230372e33253230253743253230372e34253230253743253230382e30253230253743253230382e31253230253743253230382e32253230253743253230382e33253230253743253230382e34253230253743253230382e352d627269676874677265656e2e7376673f6d61784167653d32343139323030)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml)

Note

This package is the official continuation of the now abandoned [PHP\_CodeSniffer package which was created by Squizlabs](https://github.com/squizlabs/PHP_CodeSniffer).

About
-----

[](#about)

PHP\_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP\_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.

Requirements
------------

[](#requirements)

PHP\_CodeSniffer requires PHP version 7.2.0 or greater. For more information about required and recommended PHP extensions, see the [Requirements manual page](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Requirements).

Individual sniffs may have additional requirements such as external applications and scripts. See the [Configuration Options manual page](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options) for a list of these requirements.

If you're using PHP\_CodeSniffer as part of a team, or you're running it on a [CI](https://en.wikipedia.org/wiki/Continuous_integration) server, you may want to configure your project's settings [using a configuration file](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file).

Installation
------------

[](#installation)

The easiest way to get started with PHP\_CodeSniffer is to download the Phar files for each of the commands:

```
# Download using curl
curl -OL https://phars.phpcodesniffer.com/phpcs.phar
curl -OL https://phars.phpcodesniffer.com/phpcbf.phar

# Or download using wget
wget https://phars.phpcodesniffer.com/phpcs.phar
wget https://phars.phpcodesniffer.com/phpcbf.phar

# Then test the downloaded PHARs
php phpcs.phar -h
php phpcbf.phar -h
```

These Phars are signed with the official Release key for PHPCS with the fingerprint `D91D 8696 3AF3 A29B 6520 4622 97B0 2DD8 E507 1466`.

As of PHP\_CodeSniffer 3.10.3, the provenance of PHAR files associated with a release can be verified via [GitHub Artifact Attestations](https://docs.github.com/en/actions/how-tos/secure-your-work/use-artifact-attestations/use-artifact-attestations) using the [GitHub CLI tool](https://cli.github.com/) with the following command: `gh attestation verify [phpcs|phpcbf].phar -o PHPCSStandards`.

### Composer

[](#composer)

If you use Composer, you can install PHP\_CodeSniffer system-wide with the following command:

```
composer global require "squizlabs/php_codesniffer=*"
```

Make sure you have the composer bin dir in your PATH. The default value is `~/.composer/vendor/bin/`, but you can check the value that you need to use by running `composer global config bin-dir --absolute`.

Or alternatively, include a dependency for `squizlabs/php_codesniffer` in your `composer.json` file. For example:

```
{
    "require-dev": {
        "squizlabs/php_codesniffer": "^4.0"
    }
}
```

You will then be able to run PHP\_CodeSniffer from the vendor bin directory:

```
./vendor/bin/phpcs -h
./vendor/bin/phpcbf -h
```

### Phive

[](#phive)

If you use Phive, you can install PHP\_CodeSniffer as a project tool using the following commands:

```
phive install --trust-gpg-keys D91D86963AF3A29B6520462297B02DD8E5071466 phpcs
phive install --trust-gpg-keys D91D86963AF3A29B6520462297B02DD8E5071466 phpcbf
```

You will then be able to run PHP\_CodeSniffer from the `tools` directory:

```
./tools/phpcs -h
./tools/phpcbf -h
```

### Git Clone

[](#git-clone)

You can also download the PHP\_CodeSniffer source and run the `phpcs` and `phpcbf` commands directly from the Git clone:

```
git clone https://github.com/PHPCSStandards/PHP_CodeSniffer.git
cd PHP_CodeSniffer
php bin/phpcs -h
php bin/phpcbf -h
```

Getting Started
---------------

[](#getting-started)

The default coding standard used by PHP\_CodeSniffer is the PSR12 coding standard. To check a file against the PSR12 coding standard, simply specify the file's location:

```
phpcs /path/to/code/myfile.php
```

Or if you wish to check an entire directory you can specify the directory location instead of a file.

```
phpcs /path/to/code-directory
```

If you wish to check your code against the PEAR coding standard, use the `--standard` command line argument:

```
phpcs --standard=PEAR /path/to/code-directory
```

If PHP\_CodeSniffer finds any coding standard errors, a report will be shown after running the command.

Full usage information and example reports are available on the [usage page](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage).

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

[](#documentation)

The documentation for PHP\_CodeSniffer is available on the [GitHub wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki).

Issues
------

[](#issues)

Bug reports and feature requests can be submitted on the [GitHub Issue Tracker](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues).

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

[](#contributing)

See [CONTRIBUTING.md](.github/CONTRIBUTING.md) for information.

Versioning
----------

[](#versioning)

PHP\_CodeSniffer uses a `MAJOR.MINOR.PATCH` version number format.

The `MAJOR` version is incremented when:

- backwards-incompatible changes are made to how the `phpcs` or `phpcbf` commands are used, or
- backwards-incompatible changes are made to the `ruleset.xml` format, or
- backwards-incompatible changes are made to the API used by sniff developers, or
- custom PHP\_CodeSniffer token types are removed, or
- existing sniffs are removed from PHP\_CodeSniffer entirely

The `MINOR` version is incremented when:

- new backwards-compatible features are added to the `phpcs` and `phpcbf` commands, or
- backwards-compatible changes are made to the `ruleset.xml` format, or
- backwards-compatible changes are made to the API used by sniff developers, or
- new sniffs are added to an included standard, or
- existing sniffs are removed from an included standard

> NOTE: Backwards-compatible changes to the API used by sniff developers will allow an existing sniff to continue running without producing fatal errors but may not result in the sniff reporting the same errors as it did previously without changes being required.

The `PATCH` version is incremented when:

- backwards-compatible bug fixes are made

> NOTE: As PHP\_CodeSniffer exists to report and fix issues, most bugs are the result of coding standard errors being incorrectly reported or coding standard errors not being reported when they should be. This means that the messages produced by PHP\_CodeSniffer, and the fixes it makes, are likely to be different between PATCH versions.

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance77

Regular maintenance activity

Popularity61

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 59.8% 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 ~44 days

Total

110

Last Release

59d ago

Major Versions

3.13.0 → 4.0.0beta12025-05-11

3.13.2 → 4.0.0-RC12025-06-17

3.13.4 → 4.0.02025-09-15

3.13.5 → 4.0.12025-11-10

3.x-dev → 4.x-dev2026-03-21

PHP version history (3 changes)1.4.2PHP &gt;=5.1.2

3.0.0a1PHP &gt;=5.4.0

4.0.0beta1PHP &gt;=7.2.0

### Community

Maintainers

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

---

Top Contributors

[![gsherwood](https://avatars.githubusercontent.com/u/185976?v=4)](https://github.com/gsherwood "gsherwood (5654 commits)")[![jrfnl](https://avatars.githubusercontent.com/u/663378?v=4)](https://github.com/jrfnl "jrfnl (3036 commits)")[![rodrigoprimo](https://avatars.githubusercontent.com/u/77215?v=4)](https://github.com/rodrigoprimo "rodrigoprimo (240 commits)")[![michalbundyra](https://avatars.githubusercontent.com/u/7423207?v=4)](https://github.com/michalbundyra "michalbundyra (67 commits)")[![kukulich](https://avatars.githubusercontent.com/u/260445?v=4)](https://github.com/kukulich "kukulich (60 commits)")[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (42 commits)")[![fredden](https://avatars.githubusercontent.com/u/334786?v=4)](https://github.com/fredden "fredden (41 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (39 commits)")[![klausi](https://avatars.githubusercontent.com/u/213229?v=4)](https://github.com/klausi "klausi (29 commits)")[![photodude](https://avatars.githubusercontent.com/u/10253980?v=4)](https://github.com/photodude "photodude (26 commits)")[![VincentLanglet](https://avatars.githubusercontent.com/u/9052536?v=4)](https://github.com/VincentLanglet "VincentLanglet (21 commits)")[![thiemowmde](https://avatars.githubusercontent.com/u/6576639?v=4)](https://github.com/thiemowmde "thiemowmde (18 commits)")[![andygrunwald](https://avatars.githubusercontent.com/u/320064?v=4)](https://github.com/andygrunwald "andygrunwald (18 commits)")[![MasterOdin](https://avatars.githubusercontent.com/u/1845314?v=4)](https://github.com/MasterOdin "MasterOdin (16 commits)")[![biinari](https://avatars.githubusercontent.com/u/148009?v=4)](https://github.com/biinari "biinari (16 commits)")[![sertand](https://avatars.githubusercontent.com/u/997564?v=4)](https://github.com/sertand "sertand (13 commits)")[![rmccue](https://avatars.githubusercontent.com/u/21655?v=4)](https://github.com/rmccue "rmccue (10 commits)")[![phil-davis](https://avatars.githubusercontent.com/u/1535615?v=4)](https://github.com/phil-davis "phil-davis (10 commits)")[![aboks](https://avatars.githubusercontent.com/u/815524?v=4)](https://github.com/aboks "aboks (9 commits)")[![josephzidell](https://avatars.githubusercontent.com/u/1812443?v=4)](https://github.com/josephzidell "josephzidell (9 commits)")

---

Tags

automationclicoding-standardsphpphpcbfphpcspsr1psr12psr2qastatic-analysisstandardsphpcsstatic analysis

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpcsstandards-php-codesniffer/health.svg)

```
[![Health](https://phpackages.com/badges/phpcsstandards-php-codesniffer/health.svg)](https://phpackages.com/packages/phpcsstandards-php-codesniffer)
```

###  Alternatives

[squizlabs/php_codesniffer

PHP\_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.

1.5k365.7M25.5k](/packages/squizlabs-php-codesniffer)[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)[automattic/vipwpcs

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

25510.2M145](/packages/automattic-vipwpcs)[phpcsstandards/phpcsextra

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

10324.3M44](/packages/phpcsstandards-phpcsextra)[phpcsstandards/phpcsutils

A suite of utility functions for use with PHP\_CodeSniffer

6333.4M58](/packages/phpcsstandards-phpcsutils)

PHPackages © 2026

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