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

mfn/php-cs-fixer-config

Opinionated PHP-CS-Fixer ruleset for v3.11+ via a simple \Mfn\PhpCsFixer\Config::getRules() helper. Requires setRiskyAllowed(true). Minimal repo with issues disabled—PRs welcome to discuss technical changes.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Laravel-Specific Optimization: Rules like ordered_imports and nullable_type_declaration align with Laravel’s autoloader, dependency injection, and modern PHP practices (e.g., PHP 8.4+), reducing technical debt in core Laravel patterns.
    • PSR-12 + Laravel Hybrid: Balances PSR-12 compliance with Laravel conventions (e.g., Facade usage, Eloquent naming), making it ideal for Laravel-centric codebases without enforcing rigid PSR-12-only constraints.
    • Minimal Integration Effort: Replaces custom .php-cs-fixer.php configs with a single method call, leveraging Laravel’s Composer autoloading for seamless adoption with zero architecture changes.
    • Future-Proofing: PHP 8.4 compatibility (e.g., nullable_type_declaration_for_default_null_value) ensures long-term viability without manual rule updates.
    • CI/CD Readiness: Designed for pipeline integration (e.g., GitHub Actions, Laravel Forge), enabling "shift-left" quality checks with minimal configuration.
  • Cons:

    • Provenance and Trust Risks:
      • No explicit license (legal ambiguity).
      • Disabled GitHub issues and lack of maintainer visibility.
      • Future-dated releases (2026-03-26) suggest potential abandonment or forking risks.
      • Mandatory action: Audit src/Config.php and verify maintainer legitimacy before adoption.
    • Risky Rules Enabled:
      • setRiskyAllowed(true) introduces breaking changes (e.g., native_function_invocation, no_unused_imports), which may conflict with Laravel’s dynamic method handling (e.g., Facades like Auth::user() or magic methods in Service Providers).
      • Validation required: Test against Laravel-specific edge cases (e.g., dynamic Facade calls, Blade templates, or legacy code using call_user_func_array).
    • Customization Constraints:
      • Opinionated rules (e.g., strict_types, declare_strict_types) may clash with legacy Laravel projects or teams requiring non-PSR-12 conventions (e.g., custom docblocks for Blade or legacy naming patterns).
      • Workaround: Extend the config via $rules merging (e.g., disable phpdoc_summary for Blade-specific docblocks).
    • Tooling Conflicts:
      • Potential overlaps with Laravel Pint or other formatters require explicit configuration to avoid redundant passes or conflicting rules (e.g., Pint’s Blade-specific rules vs. PHP-CS-Fixer’s PHP-only rules).
      • Recommendation: Use either this package or Pint, not both, to prevent rule conflicts.

Integration Feasibility

  • High Feasibility for Laravel Projects:

    • Drop-in Replacement: Replace existing .php-cs-fixer.php with:
      require 'vendor/autoload.php';
      return (new PhpCsFixer\Config())
          ->setFinder(…)
          ->setRiskyAllowed(true)
          ->setRules(\Mfn\PhpCsFixer\Config::getRules());
      
    • Composer Integration: Add to composer.json dev dependencies:
      "require-dev": {
          "mfn/php-cs-fixer-config": "^2.10"
      }
      
    • CI/CD Compatibility: Works with Laravel’s default CI setups (e.g., GitHub Actions, Forge) by adding:
      - run: ./vendor/bin/php-cs-fixer fix --rules=@mfn
      
  • Feasibility Blockers:

    • Risky Rules: Requires validation against Laravel-specific dynamic method calls (e.g., Facades, magic methods).
    • Provenance: Legal/compliance teams may block adoption due to lack of license or maintainer transparency.
    • Customization Needs: Projects with non-PSR-12 conventions (e.g., custom docblocks) may need to fork or override rules.

Key Questions for TPM

  1. Provenance and Compliance:

    • Has the maintainer been vetted? If not, should we fork the package under a licensed repository (e.g., laravel/php-cs-fixer-config)?
    • What is the legal stance on the "no license" clause? Can we adopt this for internal use, or is a fork necessary?
  2. Risk Mitigation:

    • How will we validate the impact of setRiskyAllowed(true) on Laravel-specific code (e.g., Facades, dynamic method calls)?
    • Should we pilot this in a non-critical Laravel project first (e.g., a legacy or internal tool) before adopting in production?
  3. Customization Strategy:

    • Will teams need to override rules frequently? If so, should we create a wrapper class (e.g., App\CsFixerConfig) to extend the base rules?
    • How will we handle conflicts with Laravel Pint or other formatters? Should we enforce a "single formatter" policy?
  4. Maintenance Plan:

    • Who will monitor updates to this package? Should we set up a GitHub watch or fork it to control the roadmap?
    • How will we handle breaking changes (e.g., if the package drops PHP 7.4 support)?
  5. Tooling Alignment:

    • Should we integrate this with Laravel’s existing tooling (e.g., laravel-shift/php-cs-fixer) or use it as a standalone config?
    • How will we ensure consistency if some projects use Pint and others use this package?

Integration Approach

Stack Fit

  • Ideal for:

    • Laravel 8+ / PHP 7.4+ Projects: Rules like nullable_type_declaration and ordered_imports optimize Laravel’s autoloader and modern PHP features.
    • PSR-12-Aligned Teams: Provides a Laravel-specific subset of PSR-12 without enforcing rigid PSR-12-only constraints (e.g., allows Laravel’s Facade naming conventions).
    • CI/CD-Driven Workflows: Designed for pipeline integration with minimal configuration (e.g., GitHub Actions, Forge).
    • Multi-Repo Teams: Standardizes formatting across 3+ Laravel projects, reducing duplication and drift.
  • Poor Fit for:

    • Non-Laravel PHP Projects: Rules like ordered_imports are Laravel-specific and may not apply to generic PHP or other frameworks.
    • Legacy Laravel (Pre-8.0): Some rules (e.g., PHP 8.4 compatibility) may not be relevant or could introduce issues.
    • Teams Requiring High Customization: Projects needing to disable strict_types or override docblock rules frequently may find the opinionated nature restrictive.

Migration Path

  1. Assessment Phase (1–2 Weeks):

    • Audit src/Config.php and verify rules against Laravel-specific edge cases (e.g., Facades, Blade, dynamic methods).
    • Run the config locally on a sample Laravel project to identify breaking changes:
      composer require --dev mfn/php-cs-fixer-config
      ./vendor/bin/php-cs-fixer fix --dry-run --rules=@mfn
      
    • Validate CI/CD compatibility by testing in a staging environment.
  2. Pilot Phase (2–4 Weeks):

    • Adopt in one non-critical Laravel project (e.g., a legacy or internal tool).
    • Monitor for:
      • False positives (e.g., no_unused_imports flagging Facade aliases).
      • Performance impact in CI/CD pipelines.
      • Developer feedback on rule changes (e.g., native_function_invocation breaking dynamic calls).
    • Document any overrides or exceptions (e.g., disable phpdoc_summary for Blade files).
  3. Rollout Phase:

    • Option A (Adopt as-is):
      • Replace .php-cs-fixer.php in all Laravel projects with the package’s config.
      • Update CI/CD pipelines to use the new ruleset.
    • Option B (Fork and Customize):
      • Fork the repository under a licensed name (e.g., laravel/php-cs-fixer-config).
      • Add Laravel-specific overrides (e.g., whitelist Facade dynamic calls).
      • Maintain the fork internally or open-source it.
    • Option C (Hybrid Approach):
      • Use the package as a base but extend it in a wrapper class:
        // app/Config/CsFixerConfig.php
        $rules = \Mfn\PhpCsFixer\Config::getRules();
        $rules['phpdoc_summary'] = false; // Disable for Blade
        return (new PhpCsFixer\Config())->setRules($rules);
        
  4. Post-Rollout:

    • Train developers on the new rules and how to override them for exceptions.
    • Set up a process for updating the package (e.g., quarterly reviews or CI checks for new versions).

Compatibility

  • PHP-CS-Fixer v3.11+: The package is explicitly designed for this version range.
  • Laravel 8+: Rules like nullable_type_declaration and ordered_imports are optimized for Laravel’s autolo
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