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.
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.
FidryConfig is immutable, so use withRules() or addRules() to layer customizations:
$config = (new FidryConfig($header, 80100))
->addRules([
'phpdoc_align' => ['align' => 'left'],
]);
FidryConfig internally uses Symfony’s and PHP-CS-Fixer’s recommended presets.minPhpVersion to match your composer.json’s php requirement to ensure compatible rules (e.g., no readonly properties on PHP < 8.1).php-cs-fixer in your linting workflow (make check-cs or GitHub Action) and fail fast on violations.addRules() or setFinder() return a new instance — always assign the result:
$config = $config->addRules([...]); // ❌ wrong if ignored
<<<EOF headers may cause issues with header-aware rules (e.g., header_comment). Keep it concise and avoid trailing blank lines.@Symfony rules). Run ./vendor/bin/php-cs-fixer -V to verify compatibility (v3.76+ required).How can I help you explore Laravel packages today?