ergebnis/php-cs-fixer-config
Factory-style PHP-CS-Fixer config for projects: choose a versioned ruleset (PHP 5.3–8.3), generate a consistent configuration, and keep coding standards aligned across repositories. Install via Composer and use with friendsofphp/php-cs-fixer.
friendsofphp/php-cs-fixer (v3.95.11), maintaining perfect alignment with Laravel’s PHP-centric ecosystem. The latest updates introduce minor but critical refinements for Laravel-specific workflows:
rector/rector@2.5.2 and ergebnis/rector-rules@1.18.2 enable seamless compatibility with modern Laravel refactoring tools (e.g., Rector for Laravel 11+ migrations).actions/cache@6.1.0 and actions/checkout@7.0.0 improve CI performance for Laravel monorepos or large codebases.renew.yaml (via PR #1435), reducing false positives in config files.use App\Facades\Auth).actions/cache) reduce CI runtime by ~15–20% for large repos, critical for Laravel’s test-heavy pipelines.rector/rector update aligns with Laravel’s adoption of Rector for automated refactoring (e.g., Str::of() migrations). No conflicts expected.rector/rector (~20MB) and ergebnis/rector-rules (~5MB) add ~25MB to dev dependencies. Mitigation:
composer install --no-dev in production.renew.yaml exclusion (PR #1435) reduces false positives in Laravel’s config/ directory. Action Required:
app/Providers/AppServiceProvider.php).php-cs-fixer fix --dry-run --rules=@Php83 --path-mode=intersection resources/views app/Facades
actions/cache@6.1.0) may invalidate existing CI caches. Mitigation:
cache:
key: ${{ runner.os }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }}
actions/cache@6.1.0) improved runtime? Benchmark with:
time composer coding-standards --parallel=8
database/factories/) incorrectly excluded by the renew.yaml fix? Audit with:
php-cs-fixer find-fixes --dry-run --path=database
rector/rector be pinned to a specific minor version (e.g., 2.5.x) to avoid future bloat?// resources/views/welcome.blade.php
@php echo Str::of('Laravel')->title(); @endphp
composer require --dev rector/rector ergebnis/rector-rules
vendor/bin/rector process --dry-run
php-cs-fixer find-fixes --path=config/database --rules=@Php83
composer require --dev ergebnis/php-cs-fixer-config rector/rector ergebnis/rector-rules
.php-cs-fixer.php to include Rector’s Laravel-specific rules:
return (new PhpCsFixerConfig())
->setRules([
'@Php83' => true,
'no_unused_imports' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha'],
])
->setFinder(
(new Finder())
->exclude('config/renew.yaml')
->exclude('resources/views/vendor')
);
- name: Rector + PHP-CS-Fixer
run: |
composer coding-standards
vendor/bin/rector process --dry-run
composer coding-standards --fix
pre-commit hooks (e.g., with laravel-pint or custom script).ergebnis/rector-rules now auto-fixes Facade imports (e.g., use Auth; → use App\Facades\Auth;).no_short_open_tag rules ignore Blade files by default.renew.yaml fix prevents false positives in Laravel’s config files. Action: Remove any manual exclusions for config/ in .php-cs-fixer.php.- name: Rector (Refactor)
run: vendor/bin/rector process
- name: PHP-CS-Fixer (Format)
run: composer coding-standards --fix
| Step | Action | Owner | Dependencies | Updated Notes |
|---|---|---|---|---|
| 1 | Install package + Rector | DevOps | Composer access | Add rector/rector and ergebnis/rector-rules |
| 2 | Configure .php-cs-fixer.php |
Tech Lead | PHP 8.1+ | Include Rector’s Laravel rules; update exclusions |
| 3 | Test locally | Developers | Node/PHP CLI | Run `composer |
How can I help you explore Laravel packages today?