driftingly/rector-laravel
Rector rules for Laravel and first-party packages like Cashier and Livewire. Automate Laravel upgrades with version-aware rule sets that detect your installed version from composer.json, plus dozens of individual rules for modernizing legacy code.
withComposerBased(laravel: true) auto-detects the installed Laravel (and Faker, Livewire, Cashier) versions and applies only the rules relevant to the target version. This converts "upgrade Laravel 11 → 13" from an unbounded, un-estimable epic into a bounded, scriptable workstream you can put a date against.composer require --dev.LARAVEL_CODE_QUALITY, LARAVEL_TYPE_DECLARATIONS, LARAVEL_STATIC_TO_INJECTION, LARAVEL_TESTING) are opt-in quality levers. A "modernization sprint" can be scoped as a discrete deliverable with a diff to show for it, rather than perpetual, invisible refactoring.LARAVEL_LEGACY_FACTORIES_TO_CLASSES and LARAVEL_FACADE_ALIASES_TO_FULL_NAMES are concrete, low-risk wins on inherited codebases — good first-ticket work for new hires and a visible early win.Adopt when:
rector.php, dry-run, then apply, set by set).Look elsewhere or de-scope when:
LARAVEL_STATIC_TO_INJECTION and LARAVEL_ELOQUENT_MAGIC_METHOD_TO_QUERY_BUILDER are opinionated and may change readability or behavior in ways the team rejects.On the signals: 1.3k stars and a steady release cadence indicate real adoption. The "0 dependents" figure reflects that this is installed as a dev dependency only — it does not mean unused. Validate against your org's own usage, not that number.
For executives: Our Laravel version determines our security posture and access to framework improvements, but major upgrades are the kind of project that slips a quarter because the work is manual and hard to estimate. This package automates the mechanical portion: it reads composer.json, applies every transformation relevant to our target version, and produces reviewable pull requests. It is MIT-licensed, free, and installed as a dev-only dependency that never ships to production. The ask is engineering time to run it behind our test suite — not budget.
For engineering leadership and the team:
withComposerBased(laravel: true). Add quality sets (LARAVEL_TYPE_DECLARATIONS, LARAVEL_CODE_QUALITY) as deliberate, separately reviewed initiatives — never bundled into an upgrade PR.ResponseHelperCallToJsonResponseRector, EmptyToBlankAndFilledFuncRector, LARAVEL_STATIC_TO_INJECTION) are opt-in for a reason: they change style and sometimes semantics.RouteActionCallableRector (helps IDE and static analysis), WhereToWhereLikeRector (depends on our DB driver), and RemoveDumpDataDeadCodeRector (a good permanent guardrail).How can I help you explore Laravel packages today?