- How does driftingly/rector-laravel detect my Laravel version for rule application?
- The package automatically reads your `composer.json` to detect the Laravel version and applies the corresponding rule set. This eliminates manual configuration for most use cases. You can override this behavior by explicitly specifying version sets in your `rector.php` config.
- Can I use this package to upgrade from Laravel 9 to 13 in a single step, or should I do it incrementally?
- While you can apply all rules at once, it’s safer to use incremental version sets like `UP_TO_LARAVEL_130` in phases. Start with non-breaking rules (e.g., `LARAVEL_CODE_QUALITY`) and test thoroughly before applying version-specific changes. Always run a dry-run first.
- Will this package break my existing code if I run it without testing?
- Yes, some rules (e.g., Facade-to-DI conversions or RouteActionCallableRector) may introduce breaking changes. Always run a dry-run (`--dry-run`) and validate with your test suite before committing changes. Use `--parallel` for large codebases to reduce runtime.
- Does driftingly/rector-laravel support Livewire or Cashier-specific refactoring rules?
- Yes, the package includes rules for Livewire and Cashier alongside Laravel core changes. These are integrated into the version-aware sets, so they’ll apply automatically if your `composer.json` lists those packages. Check the [rule overview](https://github.com/driftingly/rector-laravel/blob/main/docs/rector_rules_overview.md) for specifics.
- How do I configure custom rules, like RouteActionCallableRector, for my project’s namespace?
- Custom rules often require additional configuration in `rector.php`. For example, `RouteActionCallableRector` may need your controller namespace specified. Review the rule’s documentation in the [Rector Find Rule](https://getrector.com/find-rule?activeRectorSetGroup=laravel) page or the package’s `README` for exact syntax.
- Can I exclude certain files or directories from Rector’s transformations?
- Yes, use the `paths` or `excludePaths` options in your `rector.php` config to skip files or directories. For example, exclude third-party packages by adding `'vendor/*'` to `excludePaths`. This is useful for avoiding conflicts with non-Laravel code.
- How should I integrate driftingly/rector-laravel into my CI/CD pipeline?
- Start by running Rector in a dry-run mode as a pre-merge check in PRs to catch potential issues early. For production upgrades, consider running it as a batch job in a dedicated workflow step, followed by automated testing. Use GitHub Actions or GitLab CI with the `--dry-run` flag for safety.
- What PHP and Laravel versions does driftingly/rector-laravel support?
- The package requires PHP 8.1+ and supports Laravel 9–13 (as of 2026-04-08). It’s designed for modern Laravel projects and leverages Rector’s PHP AST engine, which is compatible with Laravel’s evolving syntax. Check the [release notes](https://github.com/driftingly/rector-laravel/releases) for updates.
- Are there alternatives to driftingly/rector-laravel for Laravel refactoring?
- Other tools like `laravel-shift/upgrade` or custom Rector sets exist, but `driftingly/rector-laravel` is the most comprehensive community-driven solution for Laravel-specific refactoring. It integrates seamlessly with Rector’s ecosystem and includes rules for first-party packages like Livewire and Cashier.
- How do I roll back changes if Rector accidentally breaks something?
- Use Git to revert changes if needed—either by resetting to a previous commit or using `git blame` to identify and fix specific files. For safety, consider creating a backup branch before running Rector in production mode. Always test thoroughly in a staging environment first.