- How do I install `driftingly/rector-laravel` for Laravel upgrades?
- Run `composer require --dev driftingly/rector-laravel` to install it as a dev dependency. No runtime dependencies or server changes are required. The package integrates directly with Rector’s existing CLI.
- Can I upgrade from Laravel 8 to 13 in one go, or should I do it incrementally?
- While possible, incremental upgrades are safer. Use `LaravelLevelSetList::UP_TO_LARAVEL_130` for a full upgrade path, but test each version jump (e.g., 8→9, 9→10) separately in a staging environment to catch edge cases.
- Does this package support Laravel Cashier or Livewire refactoring?
- Yes. The package includes rules for Laravel Cashier (e.g., subscription changes) and Livewire (e.g., component syntax updates). These are included in version-specific sets like `LaravelLevelSetList::UP_TO_LARAVEL_130`.
- How do I configure Rector to auto-detect my Laravel version from `composer.json`?
- Use `withComposerBased(laravel: true)` in your Rector config. This automatically applies the correct version-specific rules based on your `composer.json` without manual set selection.
- What’s the safest way to test Rector Laravel rules before applying them?
- Run Rector in dry mode with `--dry-run` to preview changes. Compare the diff with `git diff` and validate against unit tests or manual review. For large codebases, use `--parallel` to speed up analysis.
- Will this break existing migrations or custom logic during refactoring?
- Some rules (e.g., `RemoveModelPropertyFromFactoriesRector`) may conflict with migrations or custom logic. Test in a staging environment first, and disable problematic rules via `->withSkip()` in your config.
- Can I customize or extend the rules for my project’s specific needs?
- Yes. Use `composer make:rule` to create custom rules, or override existing ones by extending Rector’s rule classes. The package supports tailoring for project-specific patterns (e.g., naming conventions).
- Does `driftingly/rector-laravel` work with PHP 8.0 or older Laravel versions?
- No. The package requires **PHP 8.1+** and **Laravel 9+** due to Rector’s underlying dependencies. For older versions, consider upgrading PHP/Laravel first or use a legacy-compatible Rector fork.
- How do I integrate this into CI/CD for automated Laravel upgrades?
- Add a step to your pipeline (e.g., GitHub Actions) to run Rector with `--dry-run` in PR checks or nightly upgrades. Example workflows are provided in the repo. Use feature flags or canary deployments for high-risk refactors.
- What are the performance implications for large Laravel codebases?
- Large codebases may slow down analysis. Mitigate this by excluding irrelevant directories with `--exclude-paths`, running rules in parallel (`--parallel`), or splitting refactors into smaller batches (e.g., by module).