PHP CS Fixer vs Rector
Which should you use? A side-by-side look at what each one does, who it suits, what it costs, how hard it is to set up, and where each falls short.
Open source · MIT
A PHP tool that automatically fixes code to follow coding standards.
Open source · MIT
Automatically upgrades and refactors PHP code, from PHP 5.3 code up to newer PHP versions.
The short answer
Choose PHP CS Fixer if you need…
- 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
Choose Rector if you need…
- PHP teams planning to move an older codebase to a newer PHP version
- Projects using Symfony, PHPUnit, or Doctrine that want framework-specific upgrade rules
- Teams that want automated code quality checks in continuous integration
- Developers who prefer reviewing a diff before applying changes
Side-by-side
| PHP CS Fixer | Rector | |
|---|---|---|
| Type | Dev tool | Dev tool |
| Price | Free and open source | Free and open source |
| Licence | MIT | MIT |
| GitHub stars | 13.6k | 10.5k |
| Setup difficulty | Beginner | Intermediate |
| How you get it | Install with a package manager | Install with a package manager |
| Main language | PHP | PHP |
| Last code update | 5 days ago | 5 days ago |
What each one is
PHP CS Fixer
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.
Rector
Rector is a command-line tool that scans PHP code and rewrites it using a set of rules. It can move code toward newer PHP versions and framework versions, and clean up code quality issues. Teams often run it in CI so code quality is maintained automatically.
Best for
PHP CS Fixer
- 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
Rector
- PHP teams planning to move an older codebase to a newer PHP version
- Projects using Symfony, PHPUnit, or Doctrine that want framework-specific upgrade rules
- Teams that want automated code quality checks in continuous integration
- Developers who prefer reviewing a diff before applying changes
Strengths
PHP CS Fixer
- 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
Rector
- Covers PHP upgrades from 5.3 to 8.5 according to the README
- Dry-run mode shows diffs before any file is changed
- Rules can be used individually or grouped into sets
Not ideal for
PHP CS Fixer
- 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
Rector
- Non-PHP projects, since it only works on PHP code
- Teams that want fully hands-off changes without reviewing diffs, because the README recommends checking results and the tool can produce poorly formatted output
- Projects without a coding standard tool, because the README says Rector's output usually needs formatting cleanup afterward
Trade-offs
PHP CS Fixer
- 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
Rector
- Output can be poorly formatted, so a coding standard tool is needed afterward
- Parallel mode may have unresolved issues on Windows, per the README
- Files mixing PHP and HTML may need manual checking after changes
Getting started
PHP CS Fixer
Install with Composer (recommended)
composer require --dev friendsofphp/php-cs-fixerInstall alternative package if dependency conflicts occur
composer require --dev php-cs-fixer/shimRector
Install as a dev dependency
composer require rector/rector --devPreview changes on a folder without modifying files
vendor/bin/rector src --dry-runFrequently asked questions
What is the difference between PHP CS Fixer and Rector?
PHP CS Fixer: A PHP tool that automatically fixes code to follow coding standards. Rector: Automatically upgrades and refactors PHP code, from PHP 5.3 code up to newer PHP versions. PHP CS Fixer suits php teams that want consistent code style without manual review comments, while Rector suits php teams planning to move an older codebase to a newer php version.
Are PHP CS Fixer and Rector free?
PHP CS Fixer: Free and open source. Rector: Free and open source.
Which is easier to set up, PHP CS Fixer or Rector?
PHP CS Fixer is easier to get started with (rated beginner); Rector is rated intermediate and usually needs more setup.
Is PHP CS Fixer or Rector more popular?
PHP CS Fixer has more GitHub stars (13.6k) than Rector (10.5k). Popularity isn't the same as fit — check which one matches your use case above.
What are other alternatives to PHP CS Fixer and Rector?
Other options people compare them with include PHPStan.
Keep comparing
Built from our catalogue entries for both products: open-source details come from each project's README (AI-assisted, refreshed weekly) and GitHub data; AI-tool details are editorial. Spotted something wrong? Let us know from either product's page.