- How do I install this PHP-CS-Fixer config for my Laravel project?
- Run `composer require --dev m6web/php-cs-fixer-config` in your Laravel project’s root. Then create a `.php-cs-fixer.dist.php` file and extend the `BedrockStreaming` config class. The package provides a starter template in its README.
- Does this config work with Laravel 10 and PHP 8.4?
- Yes, this config is fully compatible with Laravel 10 and PHP 8.4. It includes rules like `native_function_invocation` and `declare_strict_types` that align with modern PHP features. Ensure your `composer.json` supports PHP 8.4.
- Can I customize the rules for my Laravel project?
- Absolutely. Extend the `BedrockStreaming` config class in your `.php-cs-fixer.dist.php` file and override or add rules. The README provides examples for inheritance-based customization, including enabling risky rules if needed.
- Will this break my existing Laravel 8 or PHP 7.4 codebase?
- This config drops PHP 7.4 support and may enforce strict rules like `declare_strict_types`. Use `--dry-run` to preview changes before enforcing them. For legacy code, override rules in your config or whitelist exceptions.
- How do I integrate this into GitHub Actions for CI?
- Add a GitHub Actions workflow step to run `make cs-ci` (or directly call `php-cs-fixer fix --dry-run`). The package includes a Makefile template for CI/CD. You can gate merges by setting `if: always()` in your workflow.
- Does this config include Laravel-specific rules like ordered imports or facade imports?
- No, this config focuses on PSR-12 standards. For Laravel-specific rules (e.g., `ordered_imports`, `no_unused_imports`), you’ll need to manually extend the config or consider alternatives like `laravel-pint`.
- How do I avoid false positives in my CI pipeline?
- Use `--using-cache=yes` to speed up CI runs and reduce false positives. For specific issues, override rules in your `.php-cs-fixer.dist.php` file. The `--dry-run` flag helps preview changes before enforcement.
- Can I use this with pre-commit hooks like Husky?
- Yes, integrate it with Husky by adding a pre-commit script to run `make cs` (check) or `make cs-fix` (auto-fix). The package’s Makefile includes targets for local and CI use, making it easy to adapt.
- What’s the difference between this and Laravel Pint?
- This package uses PHP-CS-Fixer with a reusable config, while Pint is a Laravel-specific wrapper for PHP-CS-Fixer. Pint may offer tighter Laravel integration (e.g., facade imports), but this config gives you more control over PSR-12 rules.
- How do I lock the PHP-CS-Fixer version to avoid breaking changes?
- Pin the PHP-CS-Fixer version in your `composer.json` (e.g., `^3.57` or `~3.57.0`). The package’s config is designed for PHP-CS-Fixer v3.57+, so locking the version ensures stability. Check the package’s `composer.json` for compatibility.