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 Extensions Laravel Package

slam/php-cs-fixer-extensions

Extensions and ready-to-use rulesets for FriendsOfPHP PHP-CS-Fixer. Adds custom fixers like final_abstract_public, final_internal_class, utf8 cleanup, inline comment spacing, function reference spacing, and PHP-only proxy fixers for consistent code style.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Standardizing Code Quality: Enables enforcement of Laravel-specific coding standards (e.g., UTF-8 encoding, abstract class finality) that go beyond PSR-12 or PHP-CS-Fixer defaults. Critical for teams adopting modern PHP (8.4+) or migrating legacy codebases.
  • Developer Experience (DX): Reduces PR review friction by auto-fixing edge cases (e.g., Doctrine entities, PHPUnit tests) that commonly cause merge conflicts. Aligns with GitHub’s "required status checks" for CI/CD.
  • Technical Debt Reduction: Automates fixes for historical inconsistencies (e.g., mixed encoding, superfluous final modifiers) without manual refactoring. Prioritizes maintainability over perfection.
  • Roadmap Alignment:
    • PHP 8.5+ Migration: Supports new features like readonly classes and PHPUnit 11.
    • Laravel 10+ Adoption: Fixers like PhpFileOnlyProxyFixer address Blade/PHTML templating quirks.
    • PHPStan Integration: Rules like no_superfluous_phpdoc_tags (allowing mixed) bridge static analysis tools.
  • Build vs. Buy:
    • Justify adoption over custom scripts by highlighting:
      • Active maintenance (monthly releases, PHP 8.5 support).
      • Zero long-term cost (MIT license, no vendor lock-in).
      • Proven reliability (68 stars, 24+ score, no critical issues).
    • Avoid reinventing if the team lacks bandwidth to maintain custom CS rules.
  • Use Cases:
    • Legacy Codebases: Fix UTF-8/encoding issues in mixed PHP/HTML files.
    • Large Teams: Standardize formatting for 100+ contributors (e.g., open-source projects).
    • Security-Critical Apps: Enforce utf8 rule to prevent encoding-based vulnerabilities.
    • CI/CD Optimization: Replace manual code reviews with automated fixes.

When to Consider This Package

  • Adopt if:

    • Your team uses PHP 8.4+ and Laravel 9+ (or Symfony with similar patterns).
    • You need custom CS rules beyond PSR-12 (e.g., Doctrine, PHPUnit, or UTF-8).
    • Your codebase includes PHTML/Blade templates or mixed PHP/HTML files.
    • You’re migrating from PHP 7.x/8.x and want to enforce modern standards.
    • Your CI/CD pipeline already uses PHP-CS-Fixer (minimal setup).
    • You prioritize UTF-8 consistency or strict type hints (e.g., PHPStan integration).
  • Look elsewhere if:

    • Your project uses PHP < 8.2 (last supported version: 8.4+).
    • You lack PHP-CS-Fixer in your toolchain (this is an extension).
    • Your team prefers minimalist standards (this adds 5+ custom rules).
    • You’re using non-Laravel frameworks (e.g., WordPress, Drupal) with divergent needs.
    • Your codebase is small (<5 devs) or greenfield (overkill for trivial projects).
    • You cannot enable risky rules (e.g., setRiskyAllowed(true) may break legacy code).

How to Pitch It (Stakeholders)

For Executives (1 Slide)

Problem: "Inconsistent code formatting slows down development, increases bugs, and raises onboarding costs. For example, UTF-8 encoding issues in Blade templates caused [X] production incidents last quarter."

Solution: *"This package extends PHP-CS-Fixer to enforce Laravel-specific standards—like UTF-8 encoding and abstract class finality—automatically. It’s a zero-cost way to:

  • Reduce PR review time by 30% (auto-fixes formatting issues).
  • Lower technical debt by standardizing edge cases (Doctrine, PHPUnit).
  • Future-proof the codebase for PHP 8.5+ and Laravel 10+."*

Ask: "Approve 1-hour setup in CI/CD to adopt this as a required status check for PRs. ROI: Faster releases, fewer bugs."


For Engineering (Technical Deep Dive)

Why This Package? *"It solves three critical pain points in our Laravel codebase:

  1. UTF-8 Inconsistencies: The Utf8Fixer ensures all files use UTF-8 (blocks encoding bugs in Blade templates).
  2. Abstract Class Chaos: FinalAbstractPublicFixer standardizes final modifiers for abstract methods (critical for Laravel’s service container).
  3. PHP 8.5+ Readiness: Supports readonly classes and PHPUnit 11 out of the box."*

Implementation Plan:

  1. Install:
    composer require --dev slam/php-cs-fixer-extensions
    
  2. Configure .php_cs:
    $config->registerCustomFixers([new SlamCsFixer\Utf8Fixer()]);
    $config->setRules(['Slam/utf8' => true]);
    
  3. Integrate with CI:
    • Add to .github/workflows/php-cs-fixer.yml:
      - name: PHP-CS-Fixer
        run: vendor/bin/php-cs-fixer fix --rules=@Slam --allow-risky=yes
      

Risks & Mitigations:

Risk Mitigation
False positives in Doctrine Test with php-cs-fixer fix --dry-run first.
PHP 8.4+ requirement Upgrade PHP in parallel (blocker: none).
setRiskyAllowed(true) Review fixers individually before enabling.

Alternatives Considered:

  • Custom Scripts: Higher maintenance cost.
  • PHP-CS-Fixer Defaults: Lacks Laravel-specific rules.
  • Manual Reviews: Scales poorly for large teams.

Next Steps:

  • Week 1: Validate fixers on a sample repo.
  • Week 2: Roll out to CI for a subset of teams.
  • Week 3: Full adoption + monitor false positives.

Key Metric: "Reduce PR review time by 20% by auto-fixing 80% of formatting issues."

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.
cadot.eu/make
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky