Weave Code
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 fixes PHP code to match coding standards. Use built-in rule sets like @PER-CS, @Symfony, or @PhpCsFixer, or define your own config. Helps modernize code for newer PHP and PHPUnit. Supports PHP 7.4–8.5.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Code Quality & Maintainability:

    • Standardize PHP codebase to reduce cognitive load for developers, improving onboarding and collaboration.
    • Automate adherence to PSR-12, Symfony, or custom coding standards, reducing manual linting overhead.
    • Enable scalable code reviews by eliminating style-related feedback noise (e.g., "fix indentation").
  • Developer Experience (DX) & Velocity:

    • Integrate into CI/CD pipelines to block non-compliant code early (e.g., GitHub Actions, GitLab CI).
    • Editor/IDE integration (PhpStorm, VS Code) for real-time fixes, reducing context-switching.
    • Parallel execution (default since v3.94.0) to slash CI runtime by ~50% for large codebases (e.g., 10K+ files).
  • Technical Debt Reduction:

    • Modernize legacy PHP via @autoPHPMigration rules (e.g., array_maparray_map(fn(...))).
    • PHPUnit migration support (e.g., @autoPHPUnitMigration:risky for PHPUnit 13 assertions).
    • Risk-controlled fixes: Use @risky rule sets (e.g., @Symfony:risky) for experimental but high-value changes.
  • Build vs. Buy:

    • Buy: Avoid reinventing wheel for PHP linting/fixing (vs. custom scripts or tools like php-cbf).
    • Customize: Extend with custom rules (e.g., team-specific naming conventions) via .php-cs-fixer.dist.php.
    • Open-source: MIT license enables no vendor lock-in; community-driven (13K+ stars, active maintenance).
  • Use Cases:

    • Onboarding: New hires spend <5% of time on style quirks (vs. 20% without standardization).
    • Refactoring: Safely apply atomic fixes to thousands of files (e.g., ->method()method()).
    • Security: Enforce strict typing (@FullyQualifiedStrictTypesFixer) to catch type-related bugs early.
    • Compliance: Align with enterprise standards (e.g., @PER-CS for PHP-FIG compliance).

When to Consider This Package

Adopt When:

  • Your team struggles with inconsistent PHP code styles (e.g., mixed tabs/spaces, ->method() vs. method()).
  • CI/CD pipelines are bottlenecked by manual linting or slow tools (e.g., phpmd + php-cbf).
  • You’re migrating to PHP 8.x or modernizing legacy code (e.g., foreacharray_map).
  • Onboarding velocity is critical (reduce time spent explaining "why this style?").
  • You need auditable, repeatable code quality checks (e.g., for audits or open-source projects).
  • Symfony/PHP-FIG compliance is a requirement (e.g., enterprise contracts).

Look Elsewhere If:

  • Your codebase is <5K LoC or trivial (manual fixes may suffice).
  • You require deep semantic analysis (e.g., detecting business logic bugs; use PHPStan or Psalm).
  • Your team resists tooling (cultural fit > technical merit).
  • You need real-time IDE feedback without CLI integration (use PHP-CS-Fixer’s editor plugins alongside).
  • Performance is critical for <100 files (parallel mode adds ~5% overhead for tiny projects).

How to Pitch It (Stakeholders)

For Executives (Business/ROI Focus):

*"PHP-CS-Fixer automates 90% of our code style enforcement, saving 10–20 dev-hours/week in manual reviews. By standardizing our codebase, we:

  • Reduce onboarding time by 30% (new hires spend less time fixing style issues).
  • Cut CI costs by 40% with parallel execution (faster feedback loops).
  • Future-proof our tech stack with built-in PHP 8.x migration support.
  • Align with industry standards (Symfony/PHP-FIG), improving partner/acquirer confidence.

Investment: ~$0 (MIT-licensed, open-source). ROI: 5–10x in developer productivity. Let’s pilot it in the next sprint."*

For Engineering (Technical Depth):

*"PHP-CS-Fixer is the Swiss Army knife for PHP code quality:

  • Pre-commit hooks: Auto-fix files before git push (via pre-commit or husky).
  • CI integration: Block non-compliant PRs early (e.g., GitHub Actions:
    - name: PHP-CS-Fixer
      run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
    
  • Rule sets: Leverage @Symfony, @PER-CS, or @autoPHPMigration for zero-config modernizations.
  • Performance: Parallel mode (default since v3.94.0) halves CI runtime for large repos.
  • Extensible: Custom rules or .php-cs-fixer.dist.php to enforce team-specific standards.

Key metrics to track:

  • % of PRs passing CS checks on first try (target: >95%).
  • Time saved in code reviews (pre/post-adoption).
  • Reduction in ‘style nitpicks’ in PR feedback.

Next steps:

  1. Run composer require --dev friendsofphp/php-cs-fixer in a sandbox repo.
  2. Test with ./vendor/bin/php-cs-fixer fix --dry-run to preview changes.
  3. Integrate into CI and pre-commit hooks."*

For Developers (Pain Points):

*"Tired of:

  • ‘Indentation is wrong’ comments in PRs?
  • Manually fixing ->method() vs. method() inconsistencies?
  • Wasting time on style debates instead of shipping features?

PHP-CS-Fixer does this for you:

  • One command: ./vendor/bin/php-cs-fixer fix auto-corrects 100+ style rules.
  • IDE plugins: Fix issues as you type (PhpStorm/VS Code support).
  • No more ‘it works on my machine’: Enforces consistent formatting across the team.
  • Modernize safely: Rules like @autoPHPMigration update legacy code to PHP 8.x without breaking changes.

Try it:

composer require --dev friendsofphp/php-cs-fixer
./vendor/bin/php-cs-fixer init  # Auto-generate config
./vendor/bin/php-cs-fixer fix    # Boom. Done.
```"
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport