PH

PHP-CS-Fixer

A tool to automatically fix PHP Coding Standards issues

Details

Language / Topic
phpPHP
Category
Linter / Formatter

Rules

balanced
- Configure in `.php-cs-fixer.php`. Use PSR-12 as the base rule set.
- Run `php-cs-fixer fix .` for formatting. Run `php-cs-fixer fix --dry-run --diff` in CI.
- Configure `.php-cs-fixer.php` with PSR-12 ruleset as baseline — add framework-specific rules (Laravel, Symfony) on top.
- Use `@PSR12` and `@PhpCsFixer` rule sets as the base configuration.
- Configure project-specific rules: `strict_types`, `ordered_imports`, `no_unused_imports`.
- Use `.php-cs-fixer.cache` in `.gitignore` — the cache speeds up incremental runs.
- Integrate with pre-commit hooks for automatic formatting before commits.