rector/rector-laravel
Community Rector extension to automate Laravel upgrades. Adds Laravel and first-party package rules (e.g., Cashier, Livewire), with version-based set providers that detect your composer.json or manual level sets to apply the right refactors for your target Laravel version.
LaravelLevelSetList) and opinionated sets (LaravelSetList), allowing granular adoption. This modularity ensures compatibility with incremental upgrades (e.g., Laravel 12 → 13) without forcing a monolithic refactor.composer make:rule, enabling TPMs to tailor the tool to niche use cases (e.g., project-specific naming conventions or legacy patterns).composer require --dev driftingly/rector-laravel), and configuration is minimal (auto-detection via composer.json or manual set selection). No runtime dependencies or server changes are required.UP_TO_LARAVEL_130 includes rules for all prior versions, reducing risk of partial migrations.RouteActionCallableRector misinterpreting controller namespaces) could introduce bugs. Mitigation: Run in dry mode (--dry-run) and review diffs.RemoveModelPropertyFromFactoriesRector) may conflict with existing migrations or custom logic. Test in a staging environment first.--parallel).--exclude-paths).withComposerBased) or manual sets for finer control?LARAVEL_CODE_QUALITY vs. LARAVEL_STATIC_TO_INJECTION)?RemoveDumpDataDeadCodeRector in debug environments)?git diff) to review changes.--watch mode).--paths.rector process in dry mode to identify affected files/rules.composer.json for Laravel/package versions to auto-configure sets.LARAVEL_CODE_QUALITY, LARAVEL_COLLECTION).LARAVEL_STATIC_TO_INJECTION, LARAVEL_ELOQUENT_MAGIC_METHOD).ResponseHelperCallToJsonResponseRector).LaravelLevelSetList for target versions.eval(), create_function()).--exclude-paths to skip problematic directories.LARAVEL_ARRAYACCESS_TO_METHOD_CALL).dd() removal may hide bugs).blank() over empty()).--dry-run and --verbose flags.rector.php.--parallel and --exclude-paths to optimize.app/Http, Team B refactors app/Models.--paths to target specific packages.| Risk | Impact | Mitigation |
|---|---|---|
| False-positive refactors | Broken functionality | Review diffs manually; use --dry-run. |
| Rule conflicts | Merge conflicts in CI | Sequence rule sets; use feature flags for critical paths. |
| Performance degradation | Slow CI builds | Cache Rector results; run in parallel. |
| Incomplete refactors | Legacy code remains | Audit with rector process --list-rules to ensure full coverage. |
| Dependency version mismatches | Rector/Laravel incompatibility | Pin versions in composer.json |
How can I help you explore Laravel packages today?