
PHP CS Fixer
A PHP tool that automatically fixes code to follow coding standards.
- Stars
- 13.6k
- Forks
- 1.7k
- Licence
- MIT
- Language
- PHP
- Last update
- 5 days ago
- Type
- Dev tool
What it is
PHP CS Fixer is a command-line tool that detects and automatically fixes style problems in PHP code so it follows a chosen coding standard. It ships with built-in rule sets such as PER-CS, Symfony and its own opinionated set, and teams can define their own style in a configuration file. It can also help modernise code toward newer PHP and PHPUnit versions.
- Run fix across a whole project to bring files in line with a chosen rule set
- Run check in a CI pipeline to flag files that do not match the standard without changing them
- Generate a base configuration file with the init command
- Use editor integrations such as PhpStorm or community plugins for VS Code and Vim
Great for
- PHP teams that want consistent code style without manual review comments
- Developers working on large PHP projects where hand-fixing style is tedious
- Projects that want to follow the PER-CS or Symfony coding standards
- Teams planning to migrate older PHP or PHPUnit code to newer syntax
Not ideal for
- Projects not written in PHP, since the tool only targets PHP code
- Users on PHP versions outside the supported range (7.4 to 8.5) unless they accept the README's 'at your own risk' option
- Anyone who wants a tool that changes code behavior checks only; some migration rules are marked risky and should be reviewed
How to get it
- 1
Install with a package manager
You'll need: PHP 7.4 to 8.5 · Composer
Install with Composer (recommended)
composer require --dev friendsofphp/php-cs-fixerInstall alternative package if dependency conflicts occur
composer require --dev php-cs-fixer/shim - 2
Run it
- Install the tool with Composer as a dev dependency
- Run ./vendor/bin/php-cs-fixer init to create a base configuration
- Run ./vendor/bin/php-cs-fixer check to see which files would change
- Run ./vendor/bin/php-cs-fixer fix to apply the fixes
- 3
Get the most out of it
- Pick a built-in rule set such as @PER-CS, @Symfony or @PhpCsFixer in your configuration file
- Write a team configuration file to define your own style
- Use the @autoPHPMigration rule sets to modernise code toward newer PHP versions
- Use check instead of fix in continuous integration to catch style drift
- Install an editor integration to format code while you work
Downloads
Strengths
- Automatically fixes issues rather than only reporting them
- Offers several established built-in rule sets to choose from
- Supports custom rules and team-specific configuration files
Trade-offs
- Support for the newest PHP versions can lag behind their release, as the README notes
- Some migration rule sets are marked risky and need careful review before use
- Editor support is native only for PhpStorm; other editors rely on community plugins
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| PHP-CS-Fixer (this) | 13.6k | Dev tool | beginner | 5 days ago | PHP teams that want consistent code style without manual review comments |
| phpstan | 14.1k | Dev tool | intermediate | 4 days ago | PHP developers who want to catch bugs earlier than tests alone allow |
| code-review-graph | 32.6k | Dev tool | beginner | 8 days ago | Developers who use an MCP-compatible AI coding assistant on a large repository |
| composer | 29.6k | Dev tool | beginner | 4 days ago | PHP developers starting a new project who want standard third-party libraries |
| SwiftLint | 19.8k | Dev tool | beginner | 21 days ago | iOS and macOS developers who want consistent Swift style across a team |
| BookStack | 19.1k | App | intermediate | 4 days ago | Teams that want an internal knowledge base they can host themselves |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.