PHP_CodeSniffer
Tokenizes PHP files and detects (and auto-fixes) violations of defined coding standards.
Repository Health
Technical Analysis
PHP_CodeSniffer is the standard toolkit for enforcing coding conventions across PHP codebases. Its phpcs command tokenizes source files and reports where they deviate from a chosen ruleset, while its companion phpcbf automatically fixes many of those violations in place, keeping teams aligned on style without manual review.
It ships with built-in standards such as PSR-1 and PSR-12 and supports fully custom rulesets, so organizations can codify their own conventions and run them locally, in editors, and in CI. This actively maintained PHPCSStandards release is the community successor to the original squizlabs project.
What You Get
- The
phpcscommand-line linter for detecting standard violations - The
phpcbfcommand for automatically fixing many violations - Built-in standards including PSR-1 and PSR-12
- Custom ruleset support via XML configuration
- An extensible sniff and tokenizer architecture for authoring rules
Common Use Cases
- Enforcing a consistent coding standard across a PHP team
- Automatically fixing style violations before commit
- Gating pull requests on coding-standard compliance in CI
- Authoring and distributing a custom organizational ruleset
Under The Hood
Architecture - The tool centers on a tokenizer that converts PHP (and CSS/JS) source into a stream of tokens, which individual Sniff classes inspect to flag or fix violations. Rulesets (XML) compose sniffs from one or more standards; the Runner orchestrates file discovery, tokenizing, sniff execution, and reporting, while phpcbf re-runs sniffs in fixing mode to apply corrections. Reports are pluggable (full, summary, checkstyle, JSON, etc.).
Tech Stack - Pure PHP with a very small runtime footprint (core ext-tokenizer, ext-xmlwriter, ext-simplexml), distributed both as a Composer package and as standalone PHARs. Its architecture is deliberately dependency-light so it can run anywhere PHP does.
Code Quality - The project is mature and rigorously self-tested, with an extensive suite covering the tokenizer and each bundled sniff. Under the PHPCSStandards maintainers it has seen renewed, consistent activity and disciplined releases, reflected in its strong maintenance-consistency health score.
API Design - As a CLI tool the developer experience is excellent: sensible defaults, discoverable options, and a clear XML ruleset format make adoption fast. Writing custom sniffs requires understanding the token stream, which is the main learning curve, but the bundled standards and thorough documentation ease the path.
Used by 4 apps in this directory
Leantime
Productivity · Project Management · Collaboration
Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira
LimeSurvey
Forms Surveys
The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.
opencloud
File Storage
Open source file management and collaboration platform that keeps your data under your control, no database required.
tirreno
Monitoring · Security
Embed security inside your product — detect threats, fraud, and abuse in real time at the application layer