This is a record of one real upgrade, not a general guide. We moved a production Laravel application (a mail platform with about 270 tests) from Laravel 12 to Laravel 13 in one pull request. Below is what actually had to change, taken from that pull request, and what we would check first next time. For anything else, the official Laravel upgrade guide is the authority.
What the pull request contained
- Laravel framework
^12to^13(the lock file resolved Laravel 13.31.0), withilluminate/supportmoved to^13. - PHPUnit moved to 12.5.
laravel/tinker^2.9to^3.0.darkaonline/l5-swagger^9.0to^11.0.saloonphp/saloon^3.0to^4.0andsaloonphp/laravel-pluginto^5.0.- One unused package stack (an RSS feed reader) removed instead of upgraded.
- One middleware class changed (see below).
The composer.json diff for the framework line is exactly this:
- "laravel/framework": "^12",
+ "laravel/framework": "^13",
- "illuminate/support": "^12",
+ "illuminate/support": "^13",
Packages that cap at the old version
One dependency, a Gmail integration package, did not allow Laravel 13 upstream. We did not wait. The team keeps a fork with a laravel-13-compat branch and points composer at it:
- "dacastro4/laravel-gmail": "v7.x-dev",
+ "dacastro4/laravel-gmail": "dev-laravel-13-compat",
A fork on a dev branch is a real maintenance cost. We treat it as temporary and will move back to a tagged release when upstream catches up. Before you start, run composer why-not laravel/framework 13.* to see every package that blocks the upgrade, so you find these on day one and not on day three.
Two packages that had been pinned to dev-master or x-dev in the old file were moved to tagged versions at the same time (aws/aws-sdk-php-laravel to ^3.11, saloonphp/laravel-plugin to ^5.0). Upgrades are a good moment to remove those pins.
The CSRF middleware rename
The app had its own VerifyCsrfToken class that extended the framework one. In Laravel 13 the framework class is PreventRequestForgery, so the import changed and the app class stayed:
-use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
+use Illuminate\Foundation\Http\Middleware\PreventRequestForgery as Middleware;
If you customise this middleware (for example to except webhook routes), search for VerifyCsrfToken before you run the test suite.
The trap: PHPUnit 12 stopped finding some of our tests
This one cost the most time. Our older tests marked themselves with doc-comment metadata:
/** @test */
public function the_image_upload_endpoint_is_not_accessible_to_guest_users()
PHPUnit 12 no longer reads doc-comment metadata such as @test and @group. Those methods were not failing. They were silently not running. In our suite that hid tests behind a green result. The fix is to use attributes:
+use PHPUnit\Framework\Attributes\Test;
...
- /** @test */
+ #[Test]
public function the_image_upload_endpoint_is_not_accessible_to_guest_users()
We converted every affected test file. The same applies to @group, @dataProvider and similar tags. A cheap check before and after any PHPUnit major upgrade: record the test count (phpunit --list-tests | wc -l), then compare it with the count after. If the number drops, tests were lost, not fixed.
What we ran to call it done
- The full suite: 267 tests and 760 assertions, green (one skipped, one marked incomplete, a few notices).
- The production Dockerfile built successfully.
One caveat from our own pull request: we verified the image in a sandbox that has no Docker daemon, so the normal CI Docker build remained the authoritative check before release.
Checklist if you are about to do the same
composer why-not laravel/framework 13.*and list every blocker.- Count your tests before you change anything.
- Search the app for classes that extend framework middleware, and for
@test,@groupand@dataProviderdoc comments. - Upgrade in one branch, run the suite, compare the test count.
- Build the production image before you merge.