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

fidry/php-cs-fixer-config

Personal base PHP-CS-Fixer configuration by Théo Fidry. Install as a dev dependency, then use FidryConfig in php-cs-fixer.dist.php with your Finder, a header comment, and minimum supported PHP version. Extend or override rules as needed.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package in your project:

composer require --dev fidry/php-cs-fixer-config

Then create or update your php-cs-fixer.dist.php (or .php-cs-fixer.php) to use FidryConfig. The simplest working setup:

<?php

declare(strict_types=1);

use Fidry\PhpCsFixerConfig\FidryConfig;
use PhpCsFixer\Finder;

$finder = Finder::create()->in(__DIR__)->name('*.php');

return (new FidryConfig(
    header: <<<EOF
This file is part of your project.

(c) Your Name <you@example.com>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF,
    minPhpVersion: 80100,
))->setFinder($finder);

Run ./vendor/bin/php-cs-fixer fix --dry-run to preview changes before applying.

Implementation Patterns

  • Base config with overrides: Extend the config only where needed — FidryConfig is immutable, so use withRules() or addRules() to layer customizations:
    $config = (new FidryConfig($header, 80100))
        ->addRules([
            'phpdoc_align' => ['align' => 'left'],
        ]);
    
  • Rule composition: Prefer adding to or modifying the existing ruleset rather than replacing it entirely. FidryConfig internally uses Symfony’s and PHP-CS-Fixer’s recommended presets.
  • Project alignment: Set minPhpVersion to match your composer.json’s php requirement to ensure compatible rules (e.g., no readonly properties on PHP < 8.1).
  • CI integration: Include php-cs-fixer in your linting workflow (make check-cs or GitHub Action) and fail fast on violations.

Gotchas and Tips

  • Config immutability: Calls like addRules() or setFinder() return a new instance — always assign the result:
    $config = $config->addRules([...]); // ❌ wrong if ignored
    
  • Header tokenization: Long or malformed <<<EOF headers may cause issues with header-aware rules (e.g., header_comment). Keep it concise and avoid trailing blank lines.
  • Rule deprecation: The config tracks upstream deprecations (e.g., removed @Symfony rules). Run ./vendor/bin/php-cs-fixer -V to verify compatibility (v3.76+ required).
  • Xdebug and performance: Enable Xdebug only when debugging rule failures — fixer runs significantly slower with it enabled.
  • Extensibility: For enterprise-level customization, fork or extend the config pattern — but consider vendoring a personal config instead to avoid upgrade drift.
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