@ghabe i'm aware of that, but why do i have to that in the first place? Why is the order changed?
And honestly that short code of the documentation is very bad. Is that global, can you apply that to some groups only, how does that work ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I just created a new laravel 12 project with multitenancy setup through stancl/tenancy .
In an old laravel 10 project i could just do
Route::middleware([
'web',
\App\Guards\UseTenantGuard::class,
\Stancl\Tenancy\Middleware\InitializeTenancyByRequestData::class,
'auth:tenant',
PreventAccessFromCentralDomains::class,
])
And it worked. In laravel 12 the order is completly ignored.... I made 2 dd() statements, one in UseTenantGuard and one in InitializeTenancyByRequestData and the one in InitializeTenancyByRequestData fired first!??????
I then printed out the middlewares with
dd(app('router')->gatherRouteMiddleware(request()->route()));
and the order is completly messed up:
array:10 [▼ // vendor/stancl/tenancy/src/Middleware/InitializeTenancyByRequestData.php:47
0 => "Stancl\Tenancy\Middleware\PreventAccessFromCentralDomains"
1 => "Stancl\Tenancy\Middleware\InitializeTenancyByRequestData"
2 => "Illuminate\Cookie\Middleware\EncryptCookies"
3 => "Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse"
4 => "Illuminate\Session\Middleware\StartSession"
5 => "Illuminate\View\Middleware\ShareErrorsFromSession"
6 => "Illuminate\Foundation\Http\Middleware\ValidateCsrfToken"
7 => "Illuminate\Auth\Middleware\Authenticate:tenant"
8 => "Illuminate\Routing\Middleware\SubstituteBindings"
9 => "App\Guards\UseTenantGuard"
]
Just what the heck is happening? Why is the order in a completely wrong order, thats not what i have defined.
Please or to participate in this conversation.