spatie/laravel-permission

Laravel 11 compatibility issues

AsjidAle opened this issue · 4 comments

Docx Fixes: Due to the new release of the Laravel framework, the directory structure has become updated but this is compatible with the old version of Laravel 11, there are being couple of issues stopping it from working:

In Laravel 11, the service providers are auto-registered as the new service providers extend the ServiceProvider class that registers automatically but Laravel-permissions are not working due to this in Laravel 11.

As well as no, more traditional old need to register in config/app.php.

in bootstrap\app.php use

->withProviders([
// Add providers here....
])

Thank! I knew that the solution but there's a need to be updated in docx on the site.

I don't understand how you're having any problem with it as-is.

Since the beginning, in all prior Laravel versions, adding this package to config/app.php was always optional due to self-registration. And it still auto-registers itself because it extends Laravel's ServiceProvider class.

use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;
use Spatie\Permission\Contracts\Permission as PermissionContract;
use Spatie\Permission\Contracts\Role as RoleContract;
class PermissionServiceProvider extends ServiceProvider

If you want to register it manually, you can, but it is not necessary.

Thanks for the your valuable time, I got it, the misunderstanding occur due to laravel 11 update in directory structure.