fabpot/php-cs-fixer
PHP CS Fixer automatically detects and fixes coding standards issues in your PHP code. It offers built-in rule sets like @PER-CS, @Symfony, and @PhpCsFixer, plus migration rules to modernise your codebase toward newer PHP and PHPUnit versions.
@autoPHPMigration, or the same config across non-Laravel PHP services in the same org.@autoPHPMigration and @autoPHPMigration:risky rule sets mechanically modernise syntax toward newer PHP. That directly shortens the critical path on "we must be off EOL PHP for security/compliance reasons" — a decision that otherwise costs weeks of senior-engineer time and blocks framework upgrades. Support spans PHP 7.4–8.5, so one tool covers the whole migration window.php-cs-fixer check is a decision about where quality budget goes: it converts an unbounded, subjective review cost into a fixed, automatable one. It also makes "is this PR reviewable?" a machine answer rather than a reviewer-mood answer..php-cs-fixer.dist.php is executable documentation of house style. It reduces time-to-first-merged-PR for new hires and removes the "which reviewer do I copy?" problem — relevant if you're deciding whether to grow the team or the contractor pool.Adopt when most of these hold:
@autoPHPMigration path is the single strongest technical argument for this specific tool over generic linters.check in CI as a hard gate, fix locally and in pre-commit hooks.Look elsewhere, or defer, when:
check as non-blocking, format directory-by-directory in dedicated PRs with tests green, then flip to blocking. Do not do a single whole-repo fix commit.--allow-unsupported-php-version=yes escape hatch, but at your own risk — do not build a release gate on an unsupported target.php-cs-fixer/shim package exists specifically for this; try it before concluding the tool is incompatible.Adoption cautions to plan for: pin the version in composer.json (release cadence is high — many patch releases with fixer-behaviour changes), treat risky rule sets as code changes requiring full test-suite sign-off, and never let the fixer run as a post-deploy or runtime step. It is a dev dependency, nothing more.
For executives (one paragraph): Engineering spends recurring, invisible time on code formatting and review nitpicks, and our PHP version upgrade is gated on manual code modernisation. PHP CS Fixer is a free, MIT-licensed, 13.5k-star, actively maintained developer tool that fixes both automatically. It's already the engine inside Laravel Pint, so it's the sanctioned path in our ecosystem rather than a novel dependency. Expected returns are shorter review cycles, smaller and more predictable PRs, faster onboarding, and a measurably shorter PHP upgrade — for roughly a day of setup plus CI minutes. There is no licensing cost, no runtime risk, and no customer-facing surface; it is a platform investment, not a product feature. The ask is engineering time, not budget.
For engineering leads (the technical case): Install as a dev dependency (composer require --dev friendsofphp/php-cs-fixer), scaffold with php-cs-fixer init, commit a .php-cs-fixer.dist.php, and wire php-cs-fixer check as a blocking CI step with php-cs-fixer fix locally and in pre-commit hooks. Start from @PER-CS or @auto — do not hand-roll a rule list. Layer @autoPHPMigration (and :risky where tests are trustworthy) as a separate, isolated PR with a green suite before merge. Pin the version, because patch releases do change fixer output. Keep the boundary clear: this fixes style and syntax modernisation; PHPStan/Psalm finds bugs. Two tools, two jobs, two CI steps.
For the wider org (the narrative): We are choosing to make code style a property of the build rather than a property of reviewer attention. That is a small, reversible, one-day decision with a well-maintained upstream, and it removes a recurring source of friction from every PR.
How can I help you explore Laravel packages today?