beste/php-cs-fixer-config
Shared PHP-CS-Fixer configuration used in BESTE projects, extending ergebnis/php-cs-fixer-config. Provides ready-made rulesets for PHP 8.1 and 8.2 to standardize code style across repositories.
Architecture fit
laravel and laravel-strict rulesets are explicitly designed for Laravel’s syntax (e.g., Artisan commands, Blade templates, dynamic use statements), reducing the need for custom configurations in Laravel projects. This aligns with Laravel’s ecosystem and avoids reinventing wheel for common formatting needs.friendsofphp/php-cs-fixer dependencies, adhering to PHP-CS-Fixer’s recommended practices. This reduces version conflicts and aligns with Laravel’s Composer-based dependency management.Integration feasibility
.php-cs-fixer.php files without breaking changes (post-3.0.0).use App\Models\${model} dynamic imports, Blade syntax in .blade.php files). This reduces the need for manual rule tweaking.Technical risk
laravel-strict preset may enforce unexpected rules (e.g., line length limits, PHPDoc alignment) that conflict with legacy codebases. Mitigation: Run php-cs-fixer fix --dry-run before full adoption.use App\${namespace}\Model)?composer require friendsofphp/php-cs-fixer:^3.0 first.--parallel and adjust CI cache strategies.@foreach formatting) may not be fully covered. Mitigation: Validate with a sample .blade.php file.function_typehint_space → type_declaration_spaces), but Laravel-specific rules might lag. Mitigation: Audit the laravel preset’s rules against Laravel’s evolving syntax.Key questions
laravel preset be extended without duplication (e.g., adding custom rules while inheriting base Laravel-specific rules)?php artisan output, migration files) that are not covered by the presets?.blade.php, .env, or composer.json files out of the box, or require additional rules?use statements (e.g., use App\Models\${model}) vs. static imports?Php81 be removed after PHP 8.1 EOL)?Stack fit
Migration path
composer show php-cs-fixer to check current version..php-cs-fixer.php or php-cs-fixer.dist.php.vendor/bin/php-cs-fixer fix app/Http/Controllers --config=vendor/beste/php-cs-fixer-config/laravel --dry-run
composer.json (dev dependency):
"require-dev": {
"beste/php-cs-fixer-config": "^3.3"
}
composer update beste/php-cs-fixer-config --with-dependencies.// .php-cs-fixer.php
<?php
return Beste\PhpCsFixerConfig\Config::laravel();
<?php
return (new Beste\PhpCsFixerConfig\Config())
->setRules([
'@PSR12' => true,
'laravel:risky' => true,
'line_ending' => true, // Override if needed
]);
.github/workflows/php-cs-fixer.yml):
- name: PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --allow-risky=yes --diff
composer require --dev laravel/pint
./vendor/bin/pint --test
php-cs-fixer fix --dry-run on the full codebase.Compatibility
Php81/Php82 presets). PHP 8.0 and below are not recommended (per changelog).@PSR12, but may override some rules (e.g., line_ending). Audit for conflicts.php artisan make:model).Sequencing
laravel preset (avoid laravel-strict initially).Maintenance
How can I help you explore Laravel packages today?