PHP CS Fixer
CLI tool that automatically fixes PHP code to follow coding standards
Repository Health
Technical Analysis
PHP CS Fixer is a command-line tool that doesn’t just detect PHP coding-standards violations like a linter — it rewrites the code to fix them. It ships built-in rule sets for widely used standards (PHP-FIG’s PER Coding Style, the Symfony coding standard, and its own opinionated @PhpCsFixer set), plus migration rule sets that help modernize a codebase toward newer PHP and PHPUnit syntax.
Teams typically run it via Composer (composer require --dev friendsofphp/php-cs-fixer) and invoke it as php-cs-fixer fix to auto-format a codebase, or php-cs-fixer check in CI to fail a build on style drift, with a project-level configuration file for defining custom rule combinations beyond the built-in sets.
What You Get
- A
php-cs-fixerCLI withfix(rewrite files) andcheck(report-only, CI-friendly) commands - Built-in rule sets for PER Coding Style, Symfony’s coding standard, and the tool’s own opinionated
@PhpCsFixerset - Auto-migration rule sets (
@autoPHPMigration,@autoPHPUnitMigration:risky) that modernize syntax toward newer PHP/PHPUnit versions - A configuration-file system (
.php-cs-fixer.php/dist.php) for composing custom rule combinations and per-project overrides - A
custom_rulesextension point for teams that need style rules the built-in fixer set doesn’t cover
Common Use Cases
- Enforcing a consistent code style across a team automatically, instead of relying on manual review comments for formatting nits
- Gating pull requests in CI with
php-cs-fixer check --dry-run, failing the build if any file doesn’t match the configured rule set - Migrating a legacy codebase’s syntax toward a newer PHP version’s idioms in bulk via the auto-migration rule sets
- Adopting a well-known standard (PER-CS, Symfony) on a new project in one command instead of hand-writing a style guide
Under The Hood
Architecture The tool centers on src/Tokenizer (a custom PHP token stream abstraction), src/Fixer (hundreds of individual fixer classes, each implementing one style rule against that token stream), src/RuleSet (named collections of fixers, e.g. @Symfony/@PER-CS), src/Runner and src/Differ (applying fixers across a fileset and computing diffs), src/Cache (incremental-run caching keyed by file hash and ruleset), and src/Console (the CLI command layer wrapping all of the above into fix/check); src/Linter cross-checks fixer output against PHP’s own syntax validity.
Tech Stack It’s a PHP 7.4–8.5 Composer package with symfony/console powering its CLI, its own token-stream/AST-adjacent tooling for source manipulation rather than relying on an external PHP parser, and a Docker-based (Dockerfile/compose.yaml) workflow supporting containerized usage in CI; box.json.dist indicates it’s also distributed as a self-contained PHAR via php-cs-fixer/shim for dependency-conflict-free installs.
Code Quality The repository has an exceptionally large test suite (1,200+ test files) covering essentially every individual fixer plus integration tests, PHPStan static analysis (phpstan.dist.neon) and Infection mutation testing (infection.json5.dist) configured for the CI pipeline, and a composer-dependency-analyser.php check — reflecting the discipline expected of a tool that itself enforces coding standards for thousands of downstream projects. Repo health score of 95/100 reflects very active, well-maintained, rapidly growing development.
API Design The CLI surface is deliberately small (init, fix, check) with rule-set selection doing most of the configuration work, so adopting a standard is typically a one-line config change, while the fixer/rule-set architecture is fully extensible for teams that need custom rules beyond the built-ins.
Used by 10 apps in this directory
BillaBear
Ecommerce · Invoicing Finance
Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.
Crater
Invoicing Finance
Open source invoicing and billing platform for freelancers and small businesses — create estimates, track expenses, accept Stripe payments, and run recurring invoices from your own server.
Fern
Developer Tools
Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.
Firecrawl
AI Development · Developer Tools
Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.
Invoice Ninja
Invoicing Finance · Project Management
Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.
Kimai
Invoicing Finance · Project Management
Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.
Mautic
Automation · Marketing · Ecommerce
The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.
Nextcloud Server
Collaboration · File Storage
Your own private cloud: self-hosted file sync, collaboration, and communication with no vendor lock-in.
Svix
Developer Tools · Automation
Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.