- How do I install driftingly/rector-laravel?
- Install it as a dev dependency with composer require --dev driftingly/rector-laravel, which also pulls in rector/rector as a peer. Add a rector.php file that returns RectorConfig::configure()->withComposerBased(laravel: true). Then run vendor/bin/rector process --dry-run to review the proposed diff before applying changes.
- Does rector-laravel support Laravel 11, 12, and 13?
- The package advertises version sets up to Laravel 13, and withComposerBased(laravel: true) applies only the rule sets up to the version detected in your composer.json. Because release metadata can be dated ahead of typical consumption, verify the current supported matrix on Packagist before depending on a specific set. The manual LaravelLevelSetList constants still exist but are deprecated in favor of Composer-based detection.
- What does withComposerBased(laravel: true) actually do?
- It registers RectorLaravel\Set\LaravelSetList::COMPOSER_BASED, which reads your composer.json and applies the version sets for Laravel plus Faker, Livewire, and Cashier when those packages are installed. This replaces the deprecated LaravelLevelSetList::UP_TO_LARAVEL_* constants with automatic version detection. It turns a Laravel upgrade into a deterministic, repeatable transformation instead of a manual migration project.
- Can I use rector-laravel in production or does it add runtime overhead?
- There is zero production footprint. The package installs as a require-dev dependency and operates over source files at build or upgrade time, so nothing ships to runtime. It adds no autoload weight, no service provider, and no configuration surface to the deployed Laravel application.
- Which first-party Laravel packages does rector-laravel cover?
- Coverage includes the Laravel framework itself plus first-party packages such as Cashier, Livewire, and Faker. Anything else, including Nova, Filament, Inertia, or Sanctum, relies on generic Laravel and community rules and needs manual review. Check the rules overview in the docs or Rector's Find Rule page for the full list.
- How do I safely run Rector on a Laravel codebase?
- Run vendor/bin/rector process --dry-run first, review the diff carefully, and rely on test coverage before committing the result. Keep upgrade automation and codebase modernisation as separate passes so each change set is small and reviewable. Pin your Rector and rector-laravel versions so results stay reproducible.
- What are the risks of automated Rector rules changing behaviour?
- Rector is a source-to-source rewriter with no semantic guarantee, so some rules alter runtime behaviour. MinutesToSecondsInCacheRector changes cache TTL semantics, WhereToWhereLikeRector requires an explicit USING_POSTGRES_DRIVER decision, and LARAVEL_STATIC_TO_INJECTION rewrites Facades to constructor injection and can cascade through call sites. Treat behaviour-changing rules as code review items and back them with tests.
- Does rector-laravel handle Blade templates, config files, or dynamic container bindings?
- The tool is PHP only. Blade templates, config files evaluated at runtime, and dynamic dispatch through app(), string container bindings, or call_user_func are known blind spots. Several rules exist precisely because those patterns are hard to reason about statically, so expect manual review outside plain PHP source.
- Can I create custom Rector rules for my Laravel app with this package?
- Yes. The package supports composer make:rule scaffolding plus a documented directory and namespace convention for custom rules. An internal platform team can encode house rules such as banned helpers or mandated JsonResponse into the same Rector pipeline. Custom rules compose with the bundled Laravel sets in one rector.php config.
- What Rector and PHP versions does driftingly/rector-laravel require?
- The documented config uses RectorConfig::configure(), which is the Rector 2.x-era API, so confirm your installed rector/rector version matches what the package release targets and pin both. Also verify that the PHP version supported by Rector matches your target codebase. Check Packagist for the current version matrix rather than assuming future-dated release metadata is already consumable.