- What Laravel versions does this package support?
- This package is explicitly designed for Laravel 5.4 and may work with 5.4–5.8. The `5.4.x-dev` tag suggests it’s tailored for legacy projects, so test thoroughly if using newer versions. Laravel 8+ is not officially supported due to architectural changes.
- How do I integrate this with an existing L5Starter Admin setup?
- Add the package via Composer, register its service provider in `config/app.php`, publish migrations/seeders, and include the sidebar menu entries in `resources/views/vendor/l5starter/admin/partials/sidebar.blade.php`. Ensure your User model uses `HasRoles` from Spatie’s package.
- Can I customize the admin UI for roles/permissions?
- Yes, override the Blade templates in `resources/views/vendor/l5starter/permission-manager/` or extend CSS/JS via Laravel Mix. The package assumes Bootstrap + Font Awesome, so conflicts may arise if your admin uses different assets.
- What if I only need Spatie’s permission system without the admin UI?
- Skip this package and use `spatie/laravel-permission` directly. It provides the core RBAC functionality (roles, permissions, middleware) without the admin scaffolding. This is the recommended approach for Laravel 8+ projects.
- How do I protect routes using roles/permissions?
- Create a custom middleware (e.g., `RoleMiddleware`) to check roles with `$request->user()->hasRole($role)`. Register it in `app/Http/Kernel.php` and apply it to routes like `Route::middleware(['role:admin'])->group(...);`.
- Are there performance concerns with role checks in high-traffic routes?
- Role checks via Spatie’s package are optimized but may add minor overhead. Cache role assignments for users if performance is critical. Test under load, especially if roles/permissions are frequently queried.
- What happens if this package stops being maintained?
- Fork the repository or migrate to alternatives like `spatie/laravel-permission` + a custom admin UI. The package is a thin wrapper around Spatie’s package, so core functionality remains usable. Plan for this risk upfront.
- Can I use this with Laravel Sanctum or Passport for API auth?
- Yes, but ensure no conflicts with middleware or user model traits. Sanctum/Passport’s auth systems work alongside Spatie’s `HasRoles` trait. Test role checks in API routes using middleware like `role:admin` or `can:access-resource`.
- How do I handle route conflicts with existing admin panels?
- The package uses `admin/roles*` and `admin/permissions*` routes by default. Rename these in the package’s route files or use middleware to guard existing admin routes. Override the `routes/web.php` entries if needed.
- What’s the backup plan if migrations or seeders don’t work?
- Manually create the `roles` and `permissions` tables using Spatie’s migration files (published via `vendor:publish`). For seeders, copy the logic from `RolesTableSeeder` into a custom seeder. Always back up your database before running migrations.