I hope you’re all right. I was wondering if you could take a look at a problem I’ve encountered in a Laravel project that uses Spatie Laravel Permission.
The mistake I’m facing is this:
Target class [Spatie\Permission\Middlewares\PermissionMiddleware] does not exist.
I have reviewed the documentation and tried some common solutions, but so far I have had no luck in finding a solution.
I very much appreciate any suggestions or ideas you may have.
Thanks in advance for your help!
spatie/laravel-permission 6.0 Laravel Framework 10.29.0 PHP 8.2.11 laravel/jetstream 4.0 livewire/livewire 3.0
Note: Make Middleware instead of Middlewares in the Path
I was also facing the same issue when I install this package but I found a Solution that could may help you
In the documentation there could be like in the kernal.php file
protected $routeMiddleware = [
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
];
You can use this in the kernal.php file
protected $routeMiddleware = [
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
];