Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Cs Fixer Laravel Package

friendsofphp/php-cs-fixer

PHP CS Fixer automatically detects and fixes coding standards issues in your PHP code. Choose from built-in rule sets like @PER-CS, @Symfony, or @PhpCsFixer, or define your own style, and modernise your codebase with ease.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • PHP CS Fixer is a dev-time CLI tool, not a runtime library. It has no place in the request lifecycle, no service provider, no facade, no config publish. In a Laravel app it lives entirely in require-dev and disappears from production images built with composer install --no-dev.
  • It parses source via PHP's tokenizer rather than bootstrapping the framework. That means it runs without a database, queue, .env, or Laravel kernel — safe in a bare CI container.
  • It occupies the "static quality gate" layer of the stack: local editor/hook → CI check → PR status. It is complementary to, not overlapping with, PHPStan/Larastan (type analysis) or Rector (structural refactoring).
  • Strategic note: Laravel Pint is a wrapper around this package. Adopting PHP CS Fixer directly is a strict superset of Pint's capability, at the cost of owning the config file and the upgrade cadence. That is the central architectural decision here, not "whether to format code."

Integration feasibility

  • Standard install is composer require --dev friendsofphp/php-cs-fixer; when Laravel's pinned Symfony components collide, the php-cs-fixer/shim variant resolves the conflict. Both paths are documented.
  • Configuration is a .php-cs-fixer.php file returning a Config with a Finder; excludes for vendor/, storage/, bootstrap/cache/, node_modules/, and IDE-helper generated files are the usual baseline.
  • First-class surfaces for adoption: init, fix, check, --dry-run, --diff, --using-cache, --parallel. Editor integration exists natively for PhpStorm and via community plugins for VS Code, Vim, Sublime, NetBeans.
  • No Laravel-specific integration work is required — this is a Composer script and a CI step, not an engineering project.

Technical risk

  • Risky rule sets are the real hazard. @auto:risky, @autoPHPMigration:risky, and @autoPHPUnitMigration:risky can alter semantics, not just whitespace. They must be opt-in, reviewed per-PR, and never introduced in the same change as the initial style baseline.
  • Version drift. Fixers are added and behavior-modified across patch releases (e.g., SingleClassElementPerStatementFixer and OrderedClassElementsFixer fixes in the v3.82.x line, VisibilityRequiredFixer promoted-property handling in v3.84.0). An unpinned ^3 with automated dependency bumps will eventually produce surprise diffs and red builds.
  • PHP version ceiling. Supported range is PHP 7.4–8.5. Running on a newer runtime requires --allow-unsupported-php-version=yes and is explicitly unsupported — a risk if the platform team upgrades PHP ahead of the fixer.
  • Blast radius of the baseline commit. Formatting an existing Laravel codebase produces a large single diff that pollutes git blame and conflicts with every open branch.
  • The supplied metadata reports "Dependents: 0." Treat that as a scanning artifact, not a signal — Laravel Pint alone makes this one of the most-depended-upon PHP dev tools in existence.

Key questions

  1. Pint or PHP CS Fixer directly? Pint gives the Laravel preset with near-zero config; PHP CS Fixer gives custom rule sets, migration fixers, and explicit control.
  2. Repo-wide enforcement from day one, or changed-files-only until the baseline lands?
  3. Which PHP versions must CI and developer machines cover, and does that intersect the 8.5 ceiling?
  4. Are risky/migration rule sets in scope now, or deferred to a separate modernization workstream?
  5. Who owns .php-cs-fixer.php and the upgrade cadence — platform, or the app team?
  6. What is the CI time budget, and is a cache volume available for .php-cs-fixer.cache?
  7. Is this a single Laravel app or a monorepo requiring multiple Finder scopes?

Integration Approach

Stack fit

  • Targets Laravel 9–12 on PHP 8.1+ as the common case. Installs as a dev dependency via Composer 2 and coexists with PHPStan/Larastan, Pest/PHPUnit, and Rector.
  • Deliberate boundary: PHP CS Fixer handles style; Rector handles structural change. Do not run both as fixers on the same CI step or you get competing rewrites and non-deterministic diffs.
  • Rule set selection maps cleanly to Laravel conventions: @PER-CS for PHP-FIG alignment, @PhpCsFixer for the opinionated baseline, @Symfony as the closest off-the-shelf approximation of Laravel's house style. Anything Laravel-specific beyond that is a small custom config, not custom fixers.

Migration path

  1. Install and initialize — add the dev dependency (or shim), run php-cs-fixer init, select a base rule set.
  2. Measure before committing — run fix --dry-run --diff on a scratch branch and quantify the churn. This is the go/no-go number.
  3. Baseline as an isolated commit — a formatting-only change with no logic edits, merged during a coordination window; record the SHA in .git-blame-ignore-revs.
  4. Gate CI — promote check to a required status check; add .php-cs-fixer.cache to .gitignore and to the CI cache.
  5. Local DX — pre-commit hook (Husky, CaptainHook, or GrumPHP) scoped to staged files; PhpStorm integration enabled via .idea project config.
  6. Ratchet — tighten rules quarterly, one rule set at a time, each as its own reviewed PR.

Compatibility

  • Validate the resolved dependency graph against Laravel's locked Symfony and PHPUnit versions before committing to a plan; the shim is the escape hatch.
  • Pin to a minor line (^3.95) rather than floating ^3, and bump deliberately. Note that recent releases explicitly add support for phpunit/phpunit:^13.2 and sebastian/diff:^9 — the package tracks the ecosystem closely, which is a positive but also a source of churn.

Sequencing

Phase Scope Exit criterion
Discovery Pint vs. direct, rule set choice, diff size estimate Decision memo + diff size
Baseline Single formatting commit, blame ignore Clean check on main
Gate CI required check, cache wired PRs blocked on style
Local DX Hooks, editor config New code never reaches CI dirty
Ratchet Incremental rule additions Quarterly review cadence established

Operational Impact

Maintenance

  • Low-to-moderate ongoing cost. The package ships frequently (v3.95.x patch line observed), so the operational task is a scheduled quarterly bump with a changelog review focused on fix: entries — those are the ones that change output on already-clean code.
  • The config file is the durable asset; treat it as reviewed code, not an artifact. One owner, versioned in the repo.
  • Cache hygiene matters: .php-cs-fixer.cache must be gitignored locally and keyed properly in CI, or stale caches produce false passes.

Support

  • MIT licensed, community-maintained, no commercial SLA. Mitigate with a named internal owner and a pinned version.
  • Support surface is unusually strong for an OSS dev tool: complete rule index, rule set docs, config reference, custom-rule guide, GitHub Discussions, and native PhpStorm integration. The PhpStorm integration materially reduces "how do I run this" tickets.
  • Failure escalation path is upstream issues/PRs, not a vendor. Budget for that in the risk register.

Scaling

  • --parallel and the result cache keep runs tractable; on a large Laravel monorepo expect low minutes, not seconds, for a cold full run.
  • Scaling levers, in order: exclude generated and vendored paths, run path-scoped on changed directories in PR jobs, cache the result file, then parallelize.
  • Multi-app monorepos need one config per app scope rather than a single root Finder, or exclusion lists grow unmanageable.

Failure modes

  • Fixer crash on syntax newer than the supported PHP ceiling — hard CI failure, blocks all PRs. Mitigation: pin the toolchain to the CI PHP matrix and upgrade the fixer before the runtime.
  • Risky fixer silently changing behavior — the highest-severity mode. Mitigation: keep risky sets out of the gate; review them as code changes.
  • Dependency conflict blocking composer update — mitigation: shim variant, or isolate the fixer in a separate CI image.
  • Version drift turning main red without any code change — mitigation: pinned minor, scheduled bumps, and a rule-change PR template.
  • Formatting churn colliding with in-flight branches — mitigation: .git-blame-ignore-revs plus a merge-window announcement.

Ramp-up

  • Single-engineer setup is under a day: install, init, config, CI step, hook. The technical work is genuinely small.
  • Team-wide adoption is the longer tail — roughly one to two sprints — and is almost entirely social: blame noise from the baseline commit, editor setup, and the habit change of not hand-formatting. Plan the communication and the merge window; do not plan a training program.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel