RBAC
Role-based access control for Laravel: roles with parent/child hierarchy, granular permissions, Blade directives, route middleware and full Gate integration. Standalone \u2014 no dependency on the security suite.
v1.1.0
MIT License
★ 0
composer require artisanpack-ui/rbac
$ composer require artisanpack-ui/rbac
✓ Installed
$ php artisan migrate
✓ Migrated roles, permissions and pivots
$user->assignRole('editor');
$user->can('posts.publish'); // true
What it does
Roles and permissions, done right
A standalone authorization layer: hierarchical roles, cached permission resolution and integration with everything Laravel already gives you \u2014 Blade, middleware and the Gate.
Roles & hierarchy
Eloquent Role and Permission models with parent/child role hierarchy.
Traits
HasRoles and HasPermissions traits with recursive, per-user cached resolution.
Middleware
permission:slug route middleware gates routes to holders of a permission.
Blade directives
@role and @permission render content based on the current user's access.
Gate integration
$user->can(), Gate::allows() and @can resolve through RBAC permission slugs.
Commands & events
Artisan CRUD for roles and assignments, plus rbac.* observer events for auditing.
Get started
Install and migrate
Add the HasRoles and HasPermissions traits to your User model, then create roles and assign them.
1 · Install
composer require artisanpack-ui/rbac
2 · Run migrations
php artisan migrate
Requirements
What you need
| Requirement | Detail |
|---|---|
| Framework | Laravel (standalone — no security suite required) |
| Models | Eloquent Role & Permission, rebindable via config |
| Config | Publishable with --tag=rbac-config |
| Extend the base Role and Permission models and rebind them through config — the pattern the CMS Framework uses for its Users module. | |
Lock things down with RBAC
Add hierarchical roles and permissions to your Laravel app in one command. Free and open source under the MIT license.
