muhammadsadeeq / laravel-upgrades-rector
Automated Laravel version upgrade rules for Rector. Supports Laravel 10 through 13 with 64 rules covering breaking changes, dependency updates, and contract migrations.
Package info
github.com/MuhammadSadeeq/laravel-upgrades-rector
Type:rector-extension
pkg:composer/muhammadsadeeq/laravel-upgrades-rector
Requires
- php: ^8.3
- rector/rector: ^1.0 || ^2.0
Requires (Dev)
- phpstan/phpstan: ^1.10 || ^2.0
- phpunit/phpunit: ^11.0
README
Laravel Upgrades Rector
Automate your Laravel upgrades with 64 Rector rules covering Laravel 10 through 13.
Installation
composer require --dev muhammadsadeeq/laravel-upgrades-rector
Usage
Preview changes:
vendor/bin/rector process --dry-run --config=vendor/muhammadsadeeq/laravel-upgrades-rector/config/laravel-13.php
Apply changes:
vendor/bin/rector process --config=vendor/muhammadsadeeq/laravel-upgrades-rector/config/laravel-13.php
Replace laravel-13.php with laravel-12.php or laravel-11.php for older upgrades.
These config names and set constants refer to the target upgrade version, so laravel-13.php / LaravelUpgradeSetList::LARAVEL_13 means “upgrade the project to Laravel 13.”
The Laravel 11, Laravel 12, and Laravel 13 sets can also rewrite the nearest project composer.json when a supported dependency update applies.
They do not update composer.lock or install new packages for you.
The ready-to-use config files run only this package's Laravel upgrade rules; they do not enable Rector's generic PHP modernization/code-style sets. Generated files under bootstrap/cache are skipped.
Recommended Upgrade Flow
# 1. Rewrite application code and supported config patterns vendor/bin/rector process --config=vendor/muhammadsadeeq/laravel-upgrades-rector/config/laravel-11.php # 2. Install the upgraded framework and package versions composer update # 3. Run your test suite and application checks php artisan test
After Rector and Composer finish, review any generated advisory comments and TODO stubs before considering the upgrade complete.
Rule Types
- Auto-fix rules rewrite code or configuration when the upgrade can be applied safely
- Advisory rules add comments when the package can identify a Laravel upgrade concern but cannot safely rewrite project-specific behavior
- Contract stub rules add required interface methods, often with TODO comments where implementation is application-specific
Examples of advisory/manual-review areas include change() migrations, relationship methods named casts(), custom password rehashing behavior, and other behavior-sensitive upgrade-guide items.
Supported Versions
| Upgrade Path | Rules |
|---|---|
| Laravel 12 → 13 | 20 rules |
| Laravel 11 → 12 | 14 rules |
| Laravel 10 → 11 | 31 rules |
Cumulative sets are available to upgrade across multiple versions at once.
Custom Configuration
<?php use Rector\Config\RectorConfig; use MuhammadSadeeq\LaravelUpgradesRector\Set\LaravelUpgradeSetList; return RectorConfig::configure() ->withSets([ LaravelUpgradeSetList::LARAVEL_13, // LARAVEL_11, LARAVEL_12, LARAVEL_13 for single-version upgrades // UP_TO_LARAVEL_12, UP_TO_LARAVEL_13 for cumulative upgrades ]) ->withPaths([ __DIR__ . '/app', __DIR__ . '/bootstrap', __DIR__ . '/config', __DIR__ . '/database', ]);
Documentation
Full Documentation — Detailed rule reference, example transformations, architecture overview, and troubleshooting.
Testing
composer test
composer analyse
Current verification: 301 tests, 429 assertions, and PHPStan at max level with zero errors.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Credits
License
The MIT License (MIT). Please see LICENSE.md for more information.