Upgrading to Laravel 13: the parts that actually matter
Laravel 13 is a small upgrade with a few sharp edges. Here's the checklist I use: dependencies, the CSRF middleware rename, cache and session hardening, and the low-impact changes worth a grep.
- Published
- Updated
- Reading time
- 3 minutes
- Written for
- Laravel 13.x
Laravel 13 landed on March 17, 2026, and the official upgrade guide estimates ten minutes for a typical app. That's honest, as long as you know which of the changes might apply to you. This is the order I work through them in.
Before anything else: Laravel 13 requires PHP 8.3 or newer (it supports 8.3 through 8.5). If your servers are on 8.2, that's your first ticket.
1. Bump your dependencies
The upgrade guide lists these composer.json changes:
{
"require": {
"laravel/framework": "^13.0",
"laravel/tinker": "^3.0"
},
"require-dev": {
"laravel/boost": "^2.0",
"phpunit/phpunit": "^12.0",
"pestphp/pest": "^4.0"
}
}Only include the packages you actually use, then run:
composer updateIf you create projects with the Laravel installer, update it too: composer global update laravel/installer, or update Herd if you use its bundled installer.
2. CSRF middleware has a new name
This is the change most likely to break something, usually a test. VerifyCsrfToken is now PreventRequestForgery, and it also checks the request's origin using the Sec-Fetch-Site header on top of the classic token check.
The old names still work as deprecated aliases, but update direct references now:
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
// Laravel 12
$this->withoutMiddleware([VerifyCsrfToken::class]);
// Laravel 13
$this->withoutMiddleware([PreventRequestForgery::class]);A quick grep finds them:
grep -rn "VerifyCsrfToken\|ValidateCsrfToken" app bootstrap routes tests3. Cache unserialization is locked down
The new default config/cache.php includes serializable_classes => false. This protects you from PHP deserialization attacks if your APP_KEY ever leaks, but it also means cached objects won't be unserialized unless you allow-list them.
If you cache arrays and scalars, you're fine. If you cache objects, list them:
// config/cache.php
'serializable_classes' => [
App\Data\CachedDashboardStats::class,
App\Support\CachedPricingSnapshot::class,
],Better still, cache arrays and rebuild objects on the way out.
4. Sessions can move to JSON (carefully)
The Laravel 13 skeleton sets session serialization to json. If you sync your config files with the new skeleton and flip php to json, every active session is invalidated and users get logged out.
If that's a problem, keep it on php for now and switch during a quiet deploy. If your sessions don't hold PHP objects, json is the safer setting long term.
5. Check upsert calls
On MySQL and MariaDB, an upsert with an empty uniqueBy used to produce invalid SQL. It now throws an InvalidArgumentException up front. Search for upsert( and make sure every call passes its unique columns.
6. Grep for the low-impact changes
These rarely bite, but they're quick to check:
- Cache prefixes and session cookie names now use hyphens (
myapp-cache-rather thanmyapp_cache_) if you rely on framework defaults. SetCACHE_PREFIX,REDIS_PREFIXandSESSION_COOKIEexplicitly to keep the old names and avoid a cold cache. JobAttemptedevent:$event->exceptionOccurred(a boolean) is replaced by$event->exception(the exception ornull).QueueBusyevent:$connectionis now$connectionName.- Domain routes are matched before non-domain routes.
- Global scopes removed inside a nested
whereclosure now apply to the whole query. If you wrote->where(fn ($q) => $q->withoutGlobalScope('active')), the outer query loses the scope too. array_first()/array_last(): Laravel 13 depends onsymfony/polyfill-php85, which defines these globals on PHP below 8.5. They don't accept a callback, so preferArr::first()andArr::last().
7. Run the tests, then the app
php artisan test
php artisan aboutabout is a nice sanity check that the framework, PHP version and drivers are what you expect.
Is it worth upgrading now?
Laravel 12 gets bug fixes until August 13, 2026 and security fixes until February 24, 2027. Laravel 13 gets security fixes until March 17, 2028. Upgrading now buys you over a year of extra runway, and the code changes are small. The versions page has the full support timeline.
The official upgrade guide is the source of truth. If something here disagrees with it, trust the guide.