dtgfranca / laravel-tools
Automated Laravel version upgrade toolkit with code transformation rules (Rector).
Requires
- php: ^8.2
- illuminate/console: ^10.0|^11.0|^12.0|^13.0
- illuminate/filesystem: ^10.0|^11.0|^12.0|^13.0
- illuminate/process: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- laravel/prompts: ^0.1|^0.2|^0.3
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.5|^11.0
README
Automated Laravel version upgrade toolkit. This package detects your current Laravel version and upgrades your application to the next major version: dependency bumps, file/class renames, config changes, migration publishing and (optionally) code transformations via Rector.
Requirements
- PHP 8.2+
- Laravel 10, 11, 12 or 13 (the package itself; the target project can be older)
For automated code transformation (AST), install
rector/rectorandrector/rector-laravelin the target project. The upgrade works without it, skipping only the Rector step.
Installation
composer require dtgfranca/laravel-tools
The service provider is auto-discovered via extra.laravel.providers.
Usage
Check the current Laravel version
php artisan laravel:version
Upgrade interactively
php artisan laravel:upgrade
You will be prompted to choose the target version.
Upgrade directly to a version
php artisan laravel:upgrade 12
Available options
php artisan laravel:upgrade --dry-run # simulate, change nothing php artisan laravel:upgrade 12 --skip-tests # do not run the test suite php artisan laravel:upgrade 12 --skip-backup # do not create a backup
Supported upgrade paths
| From | To |
|---|---|
| Laravel 8 | Laravel 9 |
| Laravel 9 | Laravel 10 |
| Laravel 10 | Laravel 11 |
| Laravel 11 | Laravel 12 |
| Laravel 12 | Laravel 13 |
What each upgrade does
- Detects the current version from
vendor/composer/installed.json. - Creates a backup under
backup_pre_update_<timestamp>/. - Updates
composer.json(framework, packages, PHP constraint). - Runs
composer update --with-all-dependencies. - Applies file/class renames (e.g.
VerifyCsrfToken→PreventRequestForgery). - Runs Rector sets (if installed).
- Publishes package migrations (Sanctum, Passport, Cashier, etc.).
- Clears caches and runs the test suite.
Configuration
Publish the config file to customize backup paths, composer command, Rector binary and test command:
php artisan vendor:publish --tag=laravel-upgrade-config
Legacy shell scripts
The original bash scripts are kept in the legacy/ directory for reference.