Description
PHP_CodeSniffer is a set of two PHP command line tools. The phpcs script tokenizes your PHP files and reports violations of a coding standard, and phpcbf automatically fixes many of those violations. It is an essential development tool for keeping code clean and consistent, especially in teams and on continuous integration servers, where a configuration file can hold the project's settings. The default standard is PSR-12. It requires PHP 7.2 or newer, and some individual sniffs need extra external tools. The project is the official continuation of PHP_CodeSniffer, which was created by Squizlabs and is now abandoned. You can install it by downloading the signed Phar files for phpcs and phpcbf, which the README says can be verified with GitHub artifact attestations. It can also be installed system wide with Composer, added as a dependency in composer.json, installed as a project tool with Phive, or run from a Git clone. The repository is open source on GitHub, and its test status is shown in the README badges.…
Highlights
- Detects coding standard violations with phpcs
- Fixes many violations automatically with phpcbf
- Default PSR-12 standard, with custom standards
- Installs as a Phar, through Composer, Phive or Git
- Requires PHP 7.2 or newer
Ratings & Reviews
No ratings yet
Be the first to rate PHP_CodeSniffer.
People also visit
PHP_CodeSniffer FAQ
What does PHP_CodeSniffer do?
It checks PHP files against a coding standard and reports violations, and phpcbf can fix many of them automatically.
Which PHP version do I need?
PHP 7.2.0 or greater, according to the requirements section.
How do I install it?
Download the signed phpcs and phpcbf Phar files, or install with Composer, Phive or a Git clone.
Which coding standard is used by default?
PSR-12. You can configure your own standard with a configuration file.
Is this the same as the old Squizlabs package?
It is the official continuation of PHP_CodeSniffer, which the README says Squizlabs created and has abandoned.
Is it free?
Yes. It is open source and the code is on GitHub.
What are the best PHP_CodeSniffer alternatives?
Popular alternatives to PHP_CodeSniffer include Phpinsights, Checkpoint and Phpmnd. See all PHP_CodeSniffer alternatives












