Overview
PHP CS Fixer is a code-style tool for PHP projects. It can inspect source files and apply configured formatting rules so code remains consistent across a team.
What it can do
The tool provides rule sets and individual rules for formatting and selected modernization tasks. Teams can use a shared configuration file to apply the same conventions locally and in automated checks.
Installation and usage
Install it as a development dependency with Composer. The usual workflow is to run the fixer against the project and review the resulting changes before committing them. A check mode can be used in automation to report files that need formatting.
Good practices
Choose a rule set that matches the project's conventions, commit the configuration and avoid running automatic changes on production files. Review risky modernization rules separately because formatting and behavior-changing transformations are not the same thing.
Official resource
PHP CS Fixer documentation: https://cs.symfony.com/
Additional notes consolidated from the previous entry
Overview
PHP CS Fixer automatically fixes many PHP coding style issues for consistent code formatting.
Example
composer require --dev friendsofphp/php-cs-fixer
vendor/bin/php-cs-fixer fix src
Commit a project configuration and review automated changes.
Official repository: PHP CS Fixer
Evaluation checklist
- Prefer official documentation and repositories.
- Check supported PHP versions and release history.
- Review installation instructions and license terms.
- Keep dependencies updated and run security checks.