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+ from MFN. Provides a ready-to-use rule array via Mfn\PhpCsFixer\Config::getRules(); enable setRiskyAllowed(true) in your php-cs-fixer config and apply the rules.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Low architectural impact: This package is a pure configuration wrapper for PHP-CS-Fixer, not a framework or library requiring deep integration. It enforces a predefined coding standard (opinionated ruleset) without altering core Laravel/PHP behavior.
  • Complementary to existing tooling: Fits seamlessly into Laravel’s PSR-12 and PHP-CS-Fixer ecosystem, acting as a standardized alternative to manual rule configuration.
  • No dependency conflicts: Since it’s a config-only package, it avoids introducing new dependencies or breaking changes to existing Laravel/PHP-CS-Fixer setups.

Integration Feasibility

  • Minimal setup: Requires only one line (require 'vendor/autoload.php') and a single method call (getRules()) to replace custom PHP-CS-Fixer rules.
  • Laravel compatibility: Works with Laravel’s built-in PHP-CS-Fixer (via php-cs-fixer package) or custom configurations in php-cs-fixer.dist.php.
  • Risky rules requirement: Mandates setRiskyAllowed(true), which may introduce non-backward-compatible changes (e.g., aggressive refactoring). Assess alignment with team standards before adoption.

Technical Risk

  • Rule rigidity: Opinionated rules may conflict with team conventions (e.g., naming, indentation, or Laravel-specific patterns like facades).
  • Future-proofing: Ruleset is tied to PHP-CS-Fixer v3.11+; upgrades may require manual validation if the package lags behind.
  • No license: Legal ambiguity (though negligible for config-only packages).
  • No community support: Disabled issues/PRs mean no official troubleshooting—reliant on PR contributions.

Key Questions

  1. Alignment with team standards: Do the rules conflict with existing Laravel/PHP-CS-Fixer configs?
  2. Risk tolerance: Is setRiskyAllowed(true) acceptable for the codebase?
  3. Maintenance overhead: Will the ruleset need custom overrides for Laravel-specific cases (e.g., Blade templates, facades)?
  4. Upgrade path: How will the package evolve if PHP-CS-Fixer updates break compatibility?
  5. Testing impact: Does the ruleset introduce false positives/negatives in CI (e.g., phpunit, pest)?

Integration Approach

Stack Fit

  • Native to Laravel/PHP-CS-Fixer: Integrates directly with:
    • Laravel’s php-cs-fixer package (via php-cs-fixer composer dependency).
    • Custom php-cs-fixer.dist.php configs (e.g., in root or tests/).
    • CI pipelines (GitHub Actions, GitLab CI) using php-cs-fixer fix.
  • No framework coupling: Works in any PHP project, not just Laravel.

Migration Path

  1. Assessment Phase:
    • Run existing PHP-CS-Fixer rules against a subset of code to baseline current compliance.
    • Compare output with this package’s rules (via php-cs-fixer --dry-run).
  2. Pilot Integration:
    • Replace setRules() in php-cs-fixer.dist.php with:
      require __DIR__.'/vendor/autoload.php';
      $rules = \Mfn\PhpCsFixer\Config::getRules();
      return (new PhpCsFixer\Config())
          ->setFinder($finder)
          ->setRiskyAllowed(true)
          ->setRules($rules);
      
    • Test with php-cs-fixer fix --dry-run.
  3. Gradual Rollout:
    • Start with non-critical branches (e.g., feature flags).
    • Monitor CI failures and whitelist exceptions if needed.
  4. CI/CD Update:
    • Update .github/workflows/php-cs-fixer.yml or equivalent to use the new config.

Compatibility

  • PHP-CS-Fixer v3.11+: Ensure project meets this requirement (check composer.json).
  • Laravel-specific edge cases:
    • Blade templates (*.blade.php) may need custom finder paths.
    • Facades/aliases (e.g., Route::) might trigger false positives for "unused imports."
  • Tooling conflicts: Verify compatibility with:
    • rector (if used for refactoring).
    • psalm/phpstan (if strict type rules differ).

Sequencing

  1. Pre-merge: Run locally before PRs to catch violations early.
  2. CI gate: Fail builds on violations (adjust threshold if needed).
  3. Post-merge: Auto-fix in CI (e.g., php-cs-fixer fix) for non-breaking changes.
  4. Periodic review: Reassess rules every 6–12 months for drift.

Operational Impact

Maintenance

  • Low ongoing effort: No active maintenance required from the team (package is static).
  • Customization risk: If rules need tweaking, forking the package may be necessary (due to disabled PRs).
  • Documentation gap: Lack of README examples or issue discussions means internal docs must cover:
    • How to override specific rules.
    • Handling false positives (e.g., Laravel-specific patterns).

Support

  • Self-service troubleshooting: No official support; rely on:
    • PHP-CS-Fixer’s docs.
    • Community-driven PRs (if any emerge).
  • Fallback plan: Maintain a backup custom config in case the package becomes unmaintained.

Scaling

  • Performance: Minimal impact—config loading is O(1).
  • Large codebases: May require parallelized fixing (PHP-CS-Fixer supports --parallel).
  • Multi-repo: Reusable via composer package, but no built-in versioning strategy for rule updates.

Failure Modes

Scenario Impact Mitigation
Rules break existing code CI failures, dev friction Whitelist exceptions or override rules.
PHP-CS-Fixer major update Config incompatibility Pin version or fork the package.
No license clarity Legal ambiguity (unlikely) Add MIT/Apache license to LICENSE.
Disabled PRs/issues Stalled customizations Fork and maintain privately.

Ramp-Up

  • Developer onboarding:
    • 15–30 mins to integrate into local/dev environments.
    • 1 hour to resolve initial false positives.
  • Team adoption:
    • 1–2 sprints to align with new standards (if rules differ significantly).
    • Training needed on:
      • Why setRiskyAllowed(true) is used.
      • How to request rule changes (via PRs).
  • CI pipeline:
    • 30 mins to update workflows (if using GitHub Actions/GitLab CI).
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope