laravel-rbac maintained by fbpkg
Description
A lightweight and flexible RBAC package for Laravel.
Author
Last update
2026/07/31 14:00
(dev-main)
License
Downloads
3
Tags
Laravel RBAC
A lightweight and flexible Role-Based Access Control (RBAC) package for Laravel.
Features
- Lightweight and framework-friendly
- Role & Permission management
- Polymorphic role assignments
- Configurable models and table names
- Configurable role types
- Laravel 11 & 12 support
- PHP 8.2+
Installation
Install the package using Composer:
composer require fbpkg/laravel-rbac
Publish the configuration file:
php artisan vendor:publish --tag=rbac-config
Publish the migrations:
php artisan vendor:publish --tag=rbac-migrations
Run the migrations:
php artisan migrate
Basic Usage
Add the HasRoles trait to your model:
use Fbpkg\Rbac\Traits\HasRoles;
class User extends Authenticatable
{
use HasRoles;
}
Assign roles:
$user->assignRole('admin');
Check roles:
$user->hasRole('admin');
$user->hasAnyRole('admin', 'manager');
$user->hasAllRoles('admin', 'manager');
Assign permissions to a role:
$role->assignPermission('users.create');
Check permissions:
$user->hasPermission('users.create');
$user->hasAnyPermission('users.create', 'users.edit');
Configuration
The package is fully configurable.
You can customize:
- Role model
- Permission model
- Table names
- Pivot table names
- Role type enum
Requirements
- PHP 8.2+
- Laravel 11.x / 12.x
License
This package is open-sourced software licensed under the MIT license.