Automatically fixes PHP code to follow coding standards
open sourceMITfree
PHP CS Fixer (the PHP Coding Standards Fixer) finds coding standard problems in PHP code and fixes them for you, rather than only reporting them as a linter does. It has built-in rule sets for PHP-FIG's PER Coding Style, Symfony's style and its own opinionated @PhpCsFixer set, and a configuration file for a team's own style, with custom rules for anything not built in. Migration sets also modernise code towards newer PHP and PHPUnit versions. It runs from Composer (with a shim package for dependency conflicts), PHIVE, Docker images on GitHub's registry or a GitHub Action, and PhpStorm supports it natively, with plugins for VS Code, Vim, Sublime Text and NetBeans. Fabien Potencier, Symfony's creator, and Dariusz Rumiński made it, and it supports PHP 7.4 to 8.5. PHP_CodeSniffer is the best-known alternative.
Ways to install
Package managers
Problems it solves
- make every PHP file in our repository follow the same code style automatically
- fail the CI build when a pull request's PHP code isn't formatted to our standard
- reformat a legacy PHP codebase to PSR-12 or PER coding style without doing it by hand
- upgrade old PHP code to use newer language features across the whole project
- format PHP on save in my editor
Features
- fixes coding standard issues, not only reports them
- check mode for CI that reports what would change
- built-in rule sets: @PER-CS, @Symfony and @PhpCsFixer
- configuration file for a project's own style
- custom rules
- migration sets to modernise code for newer PHP and PHPUnit versions
- supports PHP 7.4 to 8.5
- install with Composer, a shim package, PHIVE or Docker
- official Docker images and a GitHub Action
- native PhpStorm support and plugins for VS Code, Vim, Sublime Text and NetBeans
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what PHP CS Fixer does.
- PHP_CodeSniffer Detect and fix coding standard violations in PHP
- Easy Coding Standard (ECS) Runs PHP_CodeSniffer and PHP-CS-Fixer rules together, fast
- rustfmt A tool for formatting Rust code according to style guidelines
- Prettier An opinionated code formatter that reprints your code in one consistent style
- dart_style An opinionated, automatic Dart source code formatter
