Laravel upgrade guide: 9 to 10, 11 and 12, step by step
A live Laravel 10 application needed to move to Laravel 12 to stay supported and secure. I planned and carried out a sequential 10 → 11 → 12 upgrade, including the move to PHP 8.2+ and Carbon 3, without putting production at risk. This guide covers the whole path from Laravel 9 to 10, 11 and 12: the breaking changes at each step, a Rector setup for the mechanical changes, a testing checklist and a rollback plan.
Staying supported and secure
Every Laravel major version eventually stops receiving bug and security fixes, and packages drop support for old versions. Staying on Laravel 10 meant falling further behind on security fixes, PHP versions and the package ecosystem, and each skipped version makes the eventual upgrade harder.
One major version at a time
Jumping straight from 10 to 12 would have mixed two sets of breaking changes, making failures hard to trace. Instead, I took a sequential path:
- Audit first: list every Composer dependency, check each one's support for Laravel 11 and 12 and for PHP 8.2+, and note which needed updates or replacements.
- 10 → 11: update the framework and dependencies, work through the upgrade guide's breaking changes, and test the application.
- 11 → 12: repeat the process for the next major version.
- PHP 8.2+ and Carbon 3: resolve the behaviour changes these bring, especially in date and time handling.
Doing it step by step meant every failure could be traced to one specific change, so the fix was quick and safe.
Step 0: audit, a safety net and Rector
Three things make every later step safer:
- A dependency audit: run
composer outdated --directand, for each target version,composer why-not laravel/framework 10.0(then 11.0 and 12.0) to see which packages would block the upgrade. - A safety net: work on a separate branch and a staging copy of production, with a recent database backup. If the app has few tests, add feature tests for the critical paths (login, checkout or payments, emails, file uploads) before you change anything.
- Rector for the mechanical changes: Rector Laravel rewrites deprecated code for you. Install it with
composer require --dev driftingly/rector-laraveland add arector.phpfile to the project root:
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPaths([
__DIR__ . '/app',
__DIR__ . '/config',
__DIR__ . '/database',
__DIR__ . '/routes',
__DIR__ . '/tests',
])
->withComposerBased(laravel: true);
withComposerBased(laravel: true) reads the Laravel version installed in your project and applies the matching upgrade rules, so run it again after each version bump. Preview first with vendor/bin/rector process --dry-run, review the diff, then run vendor/bin/rector process. Rector changes code only. It does not update Composer versions or configuration, so the steps below still apply.
Laravel 9 to 10: what to change
My production upgrade started at Laravel 10, so this step follows the official Laravel 10 upgrade guide. Laravel 10 requires PHP 8.1 and Composer 2.2 or newer.
- Composer: set
laravel/frameworkto^10.0,spatie/laravel-ignitionto^2.0and, if you use them,laravel/sanctumto^3.2,doctrine/dbalto^3.0,laravel/passportto^11.0andlaravel/uito^4.0. - Minimum stability: set
"minimum-stability": "stable"incomposer.json, or remove the setting. - PHPUnit 10 (optional): remove the
processUncoveredFilesattribute fromphpunit.xml, then movenunomaduro/collisionto^7.0andphpunit/phpunitto^10.0. - Model
$datesremoved: move those columns to$casts, for example'published_at' => 'datetime'. - Database expressions: casting
DB::raw()to a string with(string)no longer works. Use$expression->getValue(DB::connection()->getQueryGrammar()). - Monolog 3: if you use Monolog directly or through a logging package, check that it supports Monolog 3.
- Testing helpers removed: the
MocksApplicationServicestrait is gone, so replaceexpectsEvents(),expectsJobs()andexpectsNotifications()withEvent::fake(),Bus::fake()andNotification::fake(). - Removed deprecations: use
dispatchSync()instead ofBus::dispatchNow(), and stop usingRedirect::home().
The official estimate is 10 minutes. Expect longer on a real app, mostly because of packages and tests.
Laravel 10 to 11: what to change
Upgrade PHP first, because Laravel 11 requires PHP 8.2 or newer. Then work through these:
- Composer: set
laravel/frameworkto^11.0andnunomaduro/collisionto^8.1. If you use them, also move Sanctum to^4.0, Passport to^12.0, Telescope to^5.0and Cashier Stripe to^15.0. - Application structure: leave it alone. Laravel 11 has a slimmer default skeleton, but the official guide advises upgraded apps not to migrate to it.
- Modifying columns: a migration that calls
change()must now repeat every modifier you want to keep, such asunsigned,defaultandcomment, or they are dropped. Runningphp artisan schema:dumpsquashes old migrations, so you do not have to edit them. - Floating-point columns: the
doubleandfloattypes were rewritten andunsignedDecimal,unsignedDoubleandunsignedFloatwere removed. - Package migrations: publish them yourself, for example
php artisan vendor:publish --tag=sanctum-migrations. In Passport, the password grant is now off by default, so enable it withPassport::enablePasswordGrant()if you rely on it. - Rate limiting:
Limitconstructors now take seconds rather than minutes, anddecayMinutesbecamedecaySeconds. - Doctrine DBAL: Laravel no longer depends on it, so remove
doctrine/dbalif nothing else needs it. UseSchema::getColumns()and similar methods for schema inspection.
Laravel 11 to 12: what to change
- Composer: set
laravel/frameworkto^12.0,phpunit/phpunitto^11.0andpestphp/pestto^3.0. - Carbon 3 is now required: Laravel 11 accepted Carbon 2 or 3, but Laravel 12 removed Carbon 2. In Carbon 3,
diffIn*methods return floats and can be negative, so check any date arithmetic and rounding. - UUIDs: the
HasUuidstrait now produces ordered UUIDv7 values. To keep ordered UUIDv4, importHasVersion4Uuids as HasUuids.
The official guides estimate 15 minutes and 5 minutes for these two upgrades, and they list every possible breaking change, of which only some will affect your app. Real production apps take longer because of third-party packages and custom code, which is where the work below came in. The same one-version-at-a-time approach applies when you move on to Laravel 13.
A testing checklist for every step
Run this after each major version, not only at the end:
- Automated tests: the full suite passes, with no new deprecation warnings in the output.
- Clean caches:
php artisan optimize:clear, thenphp artisan aboutto confirm the Laravel and PHP versions and the drivers in use. - Migrations: run
php artisan migrate --pretendagainst a copy of the production database and read the SQL before running it for real. - Critical paths by hand: sign-in and password reset, payments or checkout, emails, file uploads, and anything that calls a third-party API.
- Background work: restart workers with
php artisan queue:restart, push a test job, and check scheduled tasks withphp artisan schedule:list. - Dates and times: anything that does date arithmetic, especially when moving to Carbon 3.
- Logs: watch
storage/logsfor new warnings during the staging run and for the first hours after release.
How to undo a release safely
An upgrade is only safe if you can undo it in minutes. A plan that works:
- Deploy as a new release: put the upgraded code in a new release folder and switch a symlink to it, so rolling back means switching the link back.
- Keep the previous lock file: the old
composer.lockandvendorfolder stay with the previous release, untouched. - Back up before migrating: take a database backup right before running migrations, and avoid destructive migrations (dropping or renaming columns) in the same release.
- Keep the old PHP version available: on cPanel/WHM or a VPS, keep the previous PHP-FPM version installed so the old release can still run if you switch back.
- Decide the trigger in advance: agree which errors or failed checks mean "roll back", so nobody has to debate it during an incident.
Dependencies and breaking changes
The real work in a Laravel upgrade is rarely the framework itself. It is the packages around it and the places where the app relied on old behaviour. I resolved dependency conflicts in Composer, updated or replaced packages that lagged behind, and fixed code affected by framework and Carbon changes, testing each area before moving on.
Tech stack
- Laravel 10
- Laravel 11
- Laravel 12
- PHP 8.2+
- Carbon 3
- Composer