fbpkg / laravel-rbac
A lightweight and flexible RBAC package for Laravel.
v0.1.0
2026-07-28 19:54 UTC
Requires
- php: ^8.2
- illuminate/auth: ^11.0|^12.0
- illuminate/contracts: ^11.0|^12.0
- illuminate/database: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.20
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^11.0
This package is not auto-updated.
Last update: 2026-07-29 18:17:11 UTC
README
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.