Support the ongoing development of Laravel.io →
Laravel Routing Middleware
0

This error occurs because Laravel is trying to resolve a container binding or middleware named role, but no such class or alias is registered.

In Laravel 12, middleware aliases must be explicitly registered in bootstrap/app.php.

If you are using role (e.g. middleware('role:admin')), make sure the middleware alias is defined (e.g. from Spatie Laravel Permission) or remove/rename it.

Fix:

Register the middleware alias or use the fully qualified middleware class, then clear the cache: php artisan optimize:clear

0

Sign in to participate in this thread!

Native PHP

Your banner here too?

sherwin sherwin-cell Joined 24 Nov 2025

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.