- How do I install this package for my Laravel project?
- Run `composer require --dev ergebnis/php-cs-fixer-config` in your Laravel project directory. This adds the package as a dev dependency, making it available for development workflows like CI checks or local fixes.
- Which PHP version rule set should I use for Laravel 10.x?
- For Laravel 10.x, which requires PHP 8.1+, use the `Php81`, `Php82`, or `Php83` rule sets. These align with modern PHP features and Laravel’s latest requirements. Check your Laravel version’s PHP support docs for exact alignment.
- Can I customize the default rules for Laravel-specific patterns like Facades or Blade templates?
- Yes, you can override rules using the factory’s `withRules()` method. For example, add `'no_unused_imports' => true` to handle Laravel Facades or exclude Blade files by configuring the `finder` in your `.php-cs-fixer.php` file.
- Will this package conflict with Laravel Pint or other code style tools?
- This package replaces Laravel Pint by providing a broader PHP-CS-Fixer configuration. If you’re using Pint, you’ll need to choose one tool to avoid conflicts. PHP-CS-Fixer offers more granular control but requires manual setup for Laravel-specific rules.
- How do I integrate this into GitHub Actions for Laravel?
- Add a step to your workflow file like this: `- name: Run PHP-CS-Fixer uses: ergebnis/php-cs-fixer-config/actions/run-fixer`. Alternatively, use a custom script to run `php-cs-fixer fix --config=.php-cs-fixer.php` in your CI pipeline.
- Does this package support Blade template files (.blade.php)?
- By default, no. Blade files are often excluded from PHP-CS-Fixer rules. Use the `finder` configuration in `.php-cs-fixer.php` to exclude them or apply custom rules via third-party fixers like `spatie/php-cs-fixer-custom-fixers`.
- How do I test performance impact in CI for large Laravel codebases?
- Run `php-cs-fixer fix --dry-run --stats` in your CI to measure execution time and memory usage. Monitor the cache directory (`.build/php-cs-fixer`) for performance bottlenecks, especially if your project has thousands of files.
- Can I use this with Laravel Forge or Envoyer for deployment?
- Yes, include the `.php-cs-fixer.php` config file in your repository and ensure it’s deployed to staging/production servers. Use Forge’s deployment scripts or Envoyer’s configuration to run checks during deployment if needed.
- What happens if I upgrade PHP-CS-Fixer to a newer version?
- This package abstracts most configuration, but you may need to update your rule set (e.g., `Php81` to `Php82`) if PHP-CS-Fixer introduces breaking changes. Always check the [PHP-CS-Fixer changelog](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/main/CHANGELOG.md) for compatibility.
- How do I exclude specific directories (e.g., vendor/) from PHP-CS-Fixer?
- Configure the `finder` in your `.php-cs-fixer.php` file to exclude directories. For example, add `'exclude' => ['vendor/', 'node_modules/']` to the `finder` array to skip third-party code and build artifacts.