fbpkg/laravel-rbac

A lightweight and flexible RBAC package for Laravel.

Maintainers

Package info

github.com/fbpkg/laravel-rbac

pkg:composer/fbpkg/laravel-rbac

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v0.1.0 2026-07-28 19:54 UTC

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.