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

beste/php-cs-fixer-config

Shared PHP-CS-Fixer configuration package providing a consistent, reusable code style setup across projects. Centralizes fixer rules and presets, making it easy to enforce formatting standards in CI and keep multiple codebases aligned with minimal per-project config.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package in your project:
    composer require --dev beste/php-cs-fixer-config
    
  2. Create or update .php-cs-fixer.php to extend the shared config:
    <?php
    
    return (new Beste\PhpCsFixerConfig\Config())
        ->setUsingCache(true)
        ->setRiskyAllowed(true);
    
  3. Run the linter/fixer to verify it works:
    vendor/bin/php-cs-fixer fix --dry-run
    
  4. Optional: Configure CI (e.g., GitHub Actions) to enforce style via php-cs-fixer check.

Implementation Patterns

  • Per-project override: Use standard PHP-CS-Fixer methods like ->setRules([...]) or ->prependRule(...) for project-specific tweaks without duplicating the core rules.
  • CI enforcement: In CI, run vendor/bin/php-cs-fixer fix --dry-run --diff to fail builds on style violations.
  • Pre-commit hook: Integrate with tools like husky + lint-staged to auto-fix staged files:
    "lint-staged": {
      "*.php": ["vendor/bin/php-cs-fixer fix"]
    }
    
  • Multi-package repos: In monorepos (e.g., using Doctrine Monorepo Builder), require beste/php-cs-fixer-config once in root and reference it across subpackages via relative paths.

Gotchas and Tips

  • Risky rules: This package enables risky rules (e.g., php_unit_strict, php_unit_test_annotation). Explicitly set ->setRiskyAllowed(true) to avoid silent failures.
  • PHP version compatibility: The config targets modern PHP versions (likely ≥8.0). Adjust setPhpVersion() if supporting older versions:
    ->setPhpVersion(80100)
    
  • Caching: Enable caching (->setUsingCache(true)) to speed up repeated runs locally/CI — but ensure CI clears caches when rules change.
  • Extension points: Subclass Config in your project to add project-specific helpers (e.g., custom finder sets), then extend that class instead of copying rules.
  • Debugging: Run vendor/bin/php-cs-fixer describe to inspect enabled rules or verify rule changes after package updates.
  • Breaking changes: Since this is a shared config, updates may change rules. Pin to a specific version tag (e.g., ^1.2) to control upgrades.
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