- How do I enforce this coding standard in Laravel CI pipelines?
- Add the package as a dev dependency (`composer require --dev brandembassy/coding-standard`), then run `./vendor/bin/ecs check` in your CI. For stricter checks, include PHPStan by referencing `integration-phpstan.neon` in your `phpstan.neon`. Use GitHub/GitLab’s cache feature to speed up repeated scans.
- Does this package support Laravel 10 or only Laravel 11?
- The package officially targets Laravel 11+ (PHP 8.4+), but you can test it with Laravel 10 by disabling PHP 8.4-specific Rector rules. Use `--skip` flags in Rector or exclude non-compatible files. Check the `default-rector.php` for Laravel-specific rules before enabling.
- Can I customize the rules for my Laravel project?
- Yes. Start with `default-ecs.php` as a base, then override rules in your project’s `ecs.php`. For PHPStan, extend `integration-phpstan.neon` with your own config. Rector rules can be skipped per file or directory using the `$skipList` in your Rector config.
- What’s the performance impact of running Rector in CI?
- Rector can slow down CI if not optimized. Start with `--dry-run` to test, then parallelize it with other tools. Cache Rector’s results using tools like `rector process --cache` or GitHub Actions’ cache. For large projects, run Rector only on changed files with `--paths`.
- How do I handle false positives in Blade templates or Eloquent models?
- Exclude Blade files (e.g., `resources/views/`) from ECS/PHPStan by adding them to the `skippedPaths` in your config. For Eloquent models, test Rector’s Laravel-specific rules (e.g., enums/attributes) in a staging environment first. Use `--fix --dry-run` to preview changes before enforcing.
- Is this package compatible with PHP 8.1 or 8.2 for older Laravel apps?
- No, the package requires PHP 8.4+ due to Rector’s PHP 8.4 fixes. For older Laravel versions, either upgrade your PHP version or disable Rector rules entirely by omitting `default-rector.php`. Use feature flags or polyfills to mitigate breaking changes.
- Can I use this instead of Laravel Shift or other Laravel-specific tools?
- This package focuses on coding standards (style, static analysis) rather than Laravel-specific refactoring. For Laravel migrations (e.g., Carbon → CarbonInterface), use tools like Laravel Shift or Rector’s Laravel plugins. Document alternatives in your `UPGRADE.md` for clarity.
- How do I integrate PHPStan’s strict rules into my Laravel project?
- Include the package’s `integration-phpstan.neon` in your `phpstan.neon` file. It bundles `phpstan-strict-rules` and `phpstan-nette` by default. Adjust the `level` setting (e.g., `max`) in your config. Run PHPStan locally with `./vendor/bin/phpstan analyse` to catch issues early.
- What’s the safest way to adopt this in an existing Laravel project?
- Start by running ECS and PHPStan in CI without blocking builds. Gradually enable Rector with `--dry-run` to identify risks. Use a feature branch to test changes, then merge into production after validating no false positives. Document the migration steps in your `UPGRADE.md`.
- Does this package support PhpStorm or other IDE integrations?
- Yes. The package includes PhpStorm code style and inspection configurations (via the EA Extended plugin). Import the settings from `vendor/brandembassy/coding-standard/PhpStorm/` into your IDE to align local formatting with the standard. This reduces manual adjustments during development.