PHP_CodeSniffer

What PHP_CodeSniffer is
PHP_CodeSniffer checks PHP files against a defined coding standard by tokenizing them and identifying violations. Its companion script, phpcbf, can automatically correct coding-standard issues. Included standards are PEAR, PSR1, PSR2, PSR12, Squiz, and Zend; users can add external standards and configure checks with ruleset files. Scans can target specific files or directories and recurse into subfolders. Report choices include full, XML, Checkstyle, CSV, JSON, JUnit, Emacs, source, summary, diff, and performance formats. Parallel processing is available but disabled by default, and it requires PHP’s PCNTL extension. Installation options documented by the project include PHAR downloads, Composer, Phive, and a Git clone. PHP_CodeSniffer requires PHP version 7.2.0 or greater, while individual sniffs may have additional requirements. The project suggests configuring settings for team or CI-server use. Its repository identifies a BSD-3-Clause license, and the plan is free. The project points users to its GitHub issue tracker for bugs and feature requests and its wiki for documentation.
Who it suits
It suits PHP developers who need to check files against established or custom coding standards, including teams using CI. It may also help users who want automated corrections through phpcbf.
What it does well
- Includes multiple built-in PHP coding standards
- phpcbf can automatically correct violations
- Supports custom standards and ruleset files
- Offers a range of report formats
- Free under the BSD-3-Clause license
What to know first
- Requires PHP version 7.2.0 or greater
- Parallel processing requires PHP's PCNTL extension
- Parallel processing is disabled by default
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| PHP_CodeSniffer | BSD-3-Clause license · requires PHP 7.2.0 or greater | Free |
As github.com lists them, read 11 Oct 2026. The maker's own page has the final word.
Verdict
PHP_CodeSniffer provides configurable PHP style checks and an automatic correction script. Check the PHP requirement and any additional needs imposed by individual sniffs before installing.
Facts from PHP_CodeSniffer's own pages
- Automatic fixes
- It includes phpcbf, a script that automatically corrects coding standard violations. · github.com, 11 Oct 2026
- Built-in standards
- The included standards include PEAR, PSR1, PSR2, PSR12, Squiz, and Zend. · github.com, 11 Oct 2026
- CI usage
- The project documentation suggests configuring project settings when using PHP_CodeSniffer on a team or CI server. · github.com, 11 Oct 2026
- Custom standards
- Users can install external coding standards and configure checks with ruleset files. · github.com, 11 Oct 2026
- Download verification
- The project says its PHAR files are signed with its official release key and that release PHAR provenance can be verified through GitHub Artifact Attestations. · github.com, 11 Oct 2026
- File scope
- It checks specified files or directories and can recursively scan a directory's subfolders. · github.com, 11 Oct 2026
- Installation
- The project documents installation through PHAR downloads, Composer, Phive, or a Git clone. · github.com, 11 Oct 2026
- License
- The repository identifies PHP_CodeSniffer as BSD-3-Clause licensed. · github.com, 11 Oct 2026
- Parallel scans
- The command supports parallel processing, which requires PHP's PCNTL extension and is disabled by default. · github.com, 11 Oct 2026
- Purpose
- PHP_CodeSniffer tokenizes PHP files and detects violations of a defined coding standard. · github.com, 11 Oct 2026
- Reports
- Available report formats include full, XML, Checkstyle, CSV, JSON, JUnit, Emacs, source, summary, diff, and performance. · github.com, 11 Oct 2026
- Runtime requirement
- PHP_CodeSniffer requires PHP version 7.2.0 or greater, and individual sniffs may have additional requirements. · github.com, 11 Oct 2026
- Support
- The project directs users to its GitHub issue tracker for bug reports and feature requests and to its wiki for documentation. · github.com, 11 Oct 2026
Where PHP_CodeSniffer stands on Freedom251
- Linters#26 of 33