- What Laravel versions and PHP versions does this pack officially support?
- The pack is optimized for Laravel 10+ and PHP 8.2+. While it may work with PHP 8.1 or Laravel 9.x, you’ll need to test compatibility manually, especially for Laravel-specific rules like Eloquent query analysis. Always check the package’s changelog for version-specific notes.
- How do I integrate this into GitHub Actions for CI/CD?
- Add a workflow step like `vendor/bin/code-quality-pack analyze --format=github` to your `.github/workflows/quality.yml`. For parallel execution, split files using `--paths` or leverage GitHub’s matrix strategy. Example: `paths: ['app/Http', 'app/Models']` to target critical directories first.
- Can I customize rules for Laravel-specific patterns (e.g., Route::resource or HasFactory)?
- Yes, the pack supports rule extensions via PHPStan’s configuration or Rector’s ruleset. Fork the package or override its `phpstan.neon`/`rector.php` to add Laravel-specific checks. For example, block unused `HasFactory` in models by extending SyliusLabs’ coding standard rules.
- Will this conflict with existing tools like PHPStan or Psalm in my Laravel project?
- Minimal risk if configured properly. The pack includes PHPStan by default, so avoid duplicate installations. Use `--ignore` flags or whitelist Laravel’s dynamic code (e.g., `app/Providers`) in `phpstan.neon`. For Psalm users, disable PHPStan’s rules to prevent redundancy.
- How do I handle false positives for Laravel’s dynamic code (e.g., Blade templates or app/Providers)?
- Whitelist paths in `phpstan.neon` under `[paths.whitelist]` or use `@ignore` annotations. For Blade templates, exclude `resources/views` unless you’ve added custom validation rules. Test with `--level=5 --memory-limit=1G` to catch edge cases before CI enforcement.
- Does this pack include mutation testing (like Infection) for Laravel’s test suite?
- Yes, Infection is included and pre-configured to analyze your PHPUnit tests. Run `vendor/bin/infection` in your project root to measure test quality. For Laravel, focus on critical paths like `tests/Feature` or `tests/Unit` to avoid excessive CI runtime.
- Can I use this pack for refactoring legacy Laravel code (e.g., upgrading from PHP 7.4 to 8.2)?
- Rector is included for safe refactoring, but test thoroughly. Start with `--dry-run` and target non-critical files first. For Laravel-specific upgrades (e.g., `collect()` to `Arr::`), extend Rector’s ruleset or use Laravel’s built-in `php artisan optimize` post-refactor.
- How often are rules updated for new PHP/Laravel features (e.g., PHP 8.3 attributes or Laravel 11)?
- The pack follows PHPStan/Rector’s release cycles, typically monthly. Laravel-specific updates lag behind but are addressed in minor versions. Monitor the [GitHub releases](https://github.com/Setono/code-quality-pack/releases) and contribute fixes if needed—it’s MIT-licensed.
- Does this work with Laravel Forge/Envoyer for deploy-time analysis?
- Not natively, but you can trigger analysis via Forge’s SSH tasks or Envoyer’s post-deploy hooks. Use `vendor/bin/code-quality-pack analyze --format=text` and pipe output to logs. For CI-like checks, add a custom recipe to your Forge server’s `deploy.php`.
- What are the best alternatives if I only need static analysis for Laravel?
- For lightweight analysis, use `phpstan/extension-installer` with a custom `phpstan.neon` targeting Laravel’s namespaces. For deeper integration, consider `nunomaduro/collision` (Laravel-specific linting) or `spatie/laravel-phpstan-rules`. This pack is ideal if you want a bundled solution with Infection, Rector, and dependency analysis.