Case study · Laravel upgrade

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.

FromLaravel 10
ToLaravel 12
RuntimePHP 8.2+ · Carbon 3
My rolePlanning & execution
Why upgrade

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.

Approach

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.

Before you start

Step 0: audit, a safety net and Rector

Three things make every later step safer:

  • A dependency audit: run composer outdated --direct and, 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-laravel and add a rector.php file 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.

Step 1

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/framework to ^10.0, spatie/laravel-ignition to ^2.0 and, if you use them, laravel/sanctum to ^3.2, doctrine/dbal to ^3.0, laravel/passport to ^11.0 and laravel/ui to ^4.0.
  • Minimum stability: set "minimum-stability": "stable" in composer.json, or remove the setting.
  • PHPUnit 10 (optional): remove the processUncoveredFiles attribute from phpunit.xml, then move nunomaduro/collision to ^7.0 and phpunit/phpunit to ^10.0.
  • Model $dates removed: 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 MocksApplicationServices trait is gone, so replace expectsEvents(), expectsJobs() and expectsNotifications() with Event::fake(), Bus::fake() and Notification::fake().
  • Removed deprecations: use dispatchSync() instead of Bus::dispatchNow(), and stop using Redirect::home().

The official estimate is 10 minutes. Expect longer on a real app, mostly because of packages and tests.

Step 2

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/framework to ^11.0 and nunomaduro/collision to ^8.1. If you use them, also move Sanctum to ^4.0, Passport to ^12.0, Telescope to ^5.0 and 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 as unsigned, default and comment, or they are dropped. Running php artisan schema:dump squashes old migrations, so you do not have to edit them.
  • Floating-point columns: the double and float types were rewritten and unsignedDecimal, unsignedDouble and unsignedFloat were 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 with Passport::enablePasswordGrant() if you rely on it.
  • Rate limiting: Limit constructors now take seconds rather than minutes, and decayMinutes became decaySeconds.
  • Doctrine DBAL: Laravel no longer depends on it, so remove doctrine/dbal if nothing else needs it. Use Schema::getColumns() and similar methods for schema inspection.
Step 3

Laravel 11 to 12: what to change

  • Composer: set laravel/framework to ^12.0, phpunit/phpunit to ^11.0 and pestphp/pest to ^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 HasUuids trait now produces ordered UUIDv7 values. To keep ordered UUIDv4, import HasVersion4Uuids 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.

Testing

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, then php artisan about to confirm the Laravel and PHP versions and the drivers in use.
  • Migrations: run php artisan migrate --pretend against 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 with php artisan schedule:list.
  • Dates and times: anything that does date arithmetic, especially when moving to Carbon 3.
  • Logs: watch storage/logs for new warnings during the staging run and for the first hours after release.
Rollback plan

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.lock and vendor folder 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.
Challenges

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

Tech stack

  • Laravel 10
  • Laravel 11
  • Laravel 12
  • PHP 8.2+
  • Carbon 3
  • Composer

Results

Laravel version
12
Before10
After12
Major versions upgraded, one at a time
2
Current & supportedApplication now on Laravel 12 and PHP 8.2+.
Traceable changesEach major version upgraded and verified on its own.
Dependencies resolvedComposer conflicts and lagging packages updated or replaced.
Ready for the futureA clean base that makes the next upgrade small.

Stuck on an old Laravel version?

I can plan and carry out your upgrade step by step, without risking production.