PHPackages                             itstructure/laravel-rbac - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. itstructure/laravel-rbac

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

itstructure/laravel-rbac
========================

Laravel package for RBAC manage

3.0.18(1y ago)566.6k↓50%12[3 issues](https://github.com/itstructure/laravel-rbac/issues)MITPHPPHP &gt;=7.3.0CI failing

Since Jul 22Pushed 1y agoCompare

[ Source](https://github.com/itstructure/laravel-rbac)[ Packagist](https://packagist.org/packages/itstructure/laravel-rbac)[ RSS](/packages/itstructure-laravel-rbac/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (27)Used By (0)

Laravel RBAC package
====================

[](#laravel-rbac-package)

[![Latest Stable Version](https://camo.githubusercontent.com/a6f841e13044f8fbeac8a2d5813a97076c73411161bdc9fe4b4e5b646be148ce/68747470733a2f2f706f7365722e707567782e6f72672f69747374727563747572652f6c61726176656c2d726261632f762f737461626c65)](https://packagist.org/packages/itstructure/laravel-rbac)[![Latest Unstable Version](https://camo.githubusercontent.com/b110e3e9238ef1fab2db24d953cadaf0dcf46a772622973f5a9baa015857a7b4/68747470733a2f2f706f7365722e707567782e6f72672f69747374727563747572652f6c61726176656c2d726261632f762f756e737461626c65)](https://packagist.org/packages/itstructure/laravel-rbac)[![License](https://camo.githubusercontent.com/faedd868023a583612c0868ccd221b04b176365eb587ca6781b02d9f731f27ad/68747470733a2f2f706f7365722e707567782e6f72672f69747374727563747572652f6c61726176656c2d726261632f6c6963656e7365)](https://packagist.org/packages/itstructure/laravel-rbac)[![Total Downloads](https://camo.githubusercontent.com/14bf85f2612be0d42a9b285265402fb519a2cc043befc7cb150422d42568cc2d/68747470733a2f2f706f7365722e707567782e6f72672f69747374727563747572652f6c61726176656c2d726261632f646f776e6c6f616473)](https://packagist.org/packages/itstructure/laravel-rbac)[![Build Status](https://camo.githubusercontent.com/28a3b1eff22e1e4f4a8f0a3014db036576682d15499da14a92e0ab0ed5eb3370/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69747374727563747572652f6c61726176656c2d726261632f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/itstructure/laravel-rbac/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/dafbcbb86e32af53a09c551480dc00fef4afc2cc2c5bb91d47eb51e859006a48/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69747374727563747572652f6c61726176656c2d726261632f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/itstructure/laravel-rbac/?branch=master)

1 Introduction
--------------

[](#1-introduction)

**LaRbac** - Package for the Laravel framework which provides management with the next data:

- Roles
- Permissions
- Assign roles for users

[![RBAC package structure](https://github.com/itstructure/laravel-rbac/raw/master/laravel_rbac_structure_en.jpg)](https://github.com/itstructure/laravel-rbac/blob/master/laravel_rbac_structure_en.jpg)

2 Dependencies
--------------

[](#2-dependencies)

- laravel 8+ | 9+ | 10+ | 11+ | 12+
- Bootstrap 4 for styling
- JQuery
- php &gt;= 7.3.0
- composer

3 Installation
--------------

[](#3-installation)

**Note!**

Version **3.x** is for laravel **8+**, **9+**, **10+**, **11+**, **12+**.

Version **2.x** is for laravel **6** or **7**. You can use branch `laravel67-rbac` with **2.x** versions.

### 3.1 General installation from remote repository

[](#31-general-installation-from-remote-repository)

Run the composer command:

`composer require itstructure/laravel-rbac "^3.0.18"`

### 3.2 Next internal installation steps

[](#32-next-internal-installation-steps)

**Notes:**

- Make sure that a table for the users is already existing in your project.
- Make sure that a model for the users table is already existing in your project.

**Recommendation:**

If you don't have any layout yet, it is useful to install for example [AdminLTE](https://github.com/jeroennoten/Laravel-AdminLTE)or you can make your special any layout template. Cause in this package there is no a layout specially. But in config it is necessary to set it (see the next point 2 about a configure).

Let's go:

1. Publish files.

    **Note:** `rbac.php` config file and seeders `LaRbacDatabaseSeeder`, `PermissionSeeder`, `RoleSeeder` must be published surely!

    - To publish config run command:

        `php artisan rbac:publish --only=config`

        It stores config file to `config` folder.
    - To publish seeders run command:

        `php artisan rbac:publish --only=seeders`

        It stores seeder files to `database/seeders` folder.
    - To publish migrations run command:

        `php artisan rbac:publish --only=migrations`

        It stores migration files to `database/migrations` folder.
    - To publish views run command:

        `php artisan rbac:publish --only=views`

        It stores view files to `resources/views/vendor/rbac` folder.
    - To publish translations run command:

        `php artisan rbac:publish --only=lang`

        It stores translation files to `resources/lang/vendor/rbac` folder.
    - To publish all parts run command without `only` argument:

        `php artisan rbac:publish`

    Else you can use `--force` argument to rewrite already published files.
2. Configure published `config/rbac.php` file:

    - set `layout`. Example: `'layout' => 'adminlte::page'`
    - change `userModelClass` if it is needed to change
    - set `adminUserId` which you wanted to be with the role of administrator. **At least at the beginning stage**.

        It is necessary for the next time system to let you go into the Rbac control panel, after you assigned an administrator role for you (Later see point **4**).
    - Most likely you have to change `memberNameAttributeKey`.

        It is to display the user name in control panel by `getMemberNameAttribute()` method of `Administrable` trait. It can be **string** or a **callback**:

        ```
        'memberNameAttributeKey' => function ($row) {
            return $row->first_name . ' ' . $row->last_name;
        }
        ```
3. Tuning your `User` model (as shown in **4.1** point):

    - Implement `User` model from `RbacUserInterface`.
    - Add **roles** attribute to `$fillable`.
    - Apply `Administrable` trait.
4. Run command to run migrations and seeders:

    `php artisan rbac:database`

    Or optional:

    To run just migrations `php artisan rbac:database --only=migrate`

    To run just seeds `php artisan rbac:database --only=seed`

    - Alternative variant for seeders.

        You can set published rbac `LaRbacDatabaseSeeder` seeder class in to a special `DatabaseSeeder`:

        ```
        use Illuminate\Database\Seeder;
        ```

        ```
        class DatabaseSeeder extends Seeder
        {
            public function run()
            {
                $this->call(LaRbacDatabaseSeeder::class);
            }
        }
        ```

        and run command: `php artisan db:seed`.
5. Run command to set Admin role for user with identifier `adminUserId`, defined in **2** point:

    `php artisan rbac:admin`

4 Usage
-------

[](#4-usage)

**Notes**:

- Make sure you use a **Bootstrap 4** for styling and **JQuery** in your application.
- Make sure that a laravel initial factory authorization is already working in your application.

### 4.1 Model part

[](#41-model-part)

According with the `Itstructure\LaRbac\Interfaces\RbacUserInterface` use functions from `Itstructure\LaRbac\Traits\Administrable` trait as in example:

```
namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Itstructure\LaRbac\Interfaces\RbacUserInterface;
use Itstructure\LaRbac\Traits\Administrable;
```

```
class User extends Authenticatable implements RbacUserInterface
{
    use Notifiable, Administrable;

    protected $fillable = [
        'name', 'email', 'password', 'roles'
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];
}
```

### 4.2 Routes part

[](#42-routes-part)

There are already integrated base RBAC routes to manage **users**, **roles** and **permissions**. See in `routes.php` package file.

They are guarded by the next:

- middleware `auth` (editable by config).
- permission `can:administrate` (editable by config).

This routes allow you to go to the next routes:

- **Users section**

    For get request method

    - `http://example-domain.com/rbac/users`
    - `http://example-domain.com/rbac/users/show/{id}`
    - `http://example-domain.com/rbac/users/edit/{id}`

    For post request method

    - `http://example-domain.com/rbac/users/update/{id}`
    - `http://example-domain.com/rbac/users/delete`
- **Roles section**

    For get request method

    - `http://example-domain.com/rbac/roles`
    - `http://example-domain.com/rbac/roles/show/{id}`
    - `http://example-domain.com/rbac/roles/create`
    - `http://example-domain.com/rbac/roles/edit/{role}`

    For post request method

    - `http://example-domain.com/rbac/roles/store`
    - `http://example-domain.com/rbac/roles/update/{role}`
    - `http://example-domain.com/rbac/roles/delete`
- **Permissions section**

    For get request method

    - `http://example-domain.com/rbac/permissions`
    - `http://example-domain.com/rbac/permissions/show/{id}`
    - `http://example-domain.com/rbac/permissions/create`
    - `http://example-domain.com/rbac/permissions/edit/{permission}`

    For post request method

    - `http://example-domain.com/rbac/permissions/store`
    - `http://example-domain.com/rbac/permissions/update/{permission}`
    - `http://example-domain.com/rbac/permissions/delete`

### 4.3 Gates part

[](#43-gates-part)

There are already integrated base RBAC gates to access control in your application to some of the resources. See provider file `RbacAuthServiceProvider.php`.

It provides the next gate definitions:

- `administrate`
- `assign-role`
- `delete-member`
- `view-record`
- `create-record`
- `update-record`
- `delete-record`
- `publish-record`

Read more in [Laravel gates](https://laravel.com/docs/9.x/authorization#gates)

5 View examples
---------------

[](#5-view-examples)

**Users**

[![RBAC package structure](https://github.com/itstructure/laravel-rbac/raw/master/laravel_rbac_users_en.JPG)](https://github.com/itstructure/laravel-rbac/blob/master/laravel_rbac_users_en.JPG)

**Roles**

[![RBAC package structure](https://github.com/itstructure/laravel-rbac/raw/master/laravel_rbac_roles_en.JPG)](https://github.com/itstructure/laravel-rbac/blob/master/laravel_rbac_roles_en.JPG)

**Permissions**

[![RBAC package structure](https://github.com/itstructure/laravel-rbac/raw/master/laravel_rbac_permissions_en.JPG)](https://github.com/itstructure/laravel-rbac/blob/master/laravel_rbac_permissions_en.JPG)

License
-------

[](#license)

Copyright © 2018-2025 Andrey Girnik .

Licensed under the [MIT license](http://opensource.org/licenses/MIT). See LICENSE.txt for details.

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance45

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~104 days

Recently: every ~57 days

Total

24

Last Release

435d ago

Major Versions

1.1.1 → 2.0.02020-07-13

2.0.1 → 3.0.02020-09-09

PHP version history (3 changes)1.0.0PHP &gt;=7.1.0

2.0.0PHP &gt;=7.2.0

3.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31563329?v=4)[Andrey Girnik](/maintainers/itstructure)[@itstructure](https://github.com/itstructure)

---

Top Contributors

[![itstructure](https://avatars.githubusercontent.com/u/31563329?v=4)](https://github.com/itstructure "itstructure (26 commits)")

---

Tags

laravellaravel-rbacpermissionrbacrolelaravelpermissionrbacprofilerole

### Embed Badge

![Health badge](/badges/itstructure-laravel-rbac/health.svg)

```
[![Health](https://phpackages.com/badges/itstructure-laravel-rbac/health.svg)](https://phpackages.com/packages/itstructure-laravel-rbac)
```

###  Alternatives

[efficiently/authority-controller

AuthorityController is an PHP authorization library for Laravel 5 which restricts what resources a given user is allowed to access.

15433.2k](/packages/efficiently-authority-controller)[dlnsk/h-rbac

Based on native Laravel's gates and policies. Hierarchical RBAC with callbacks.

378.3k](/packages/dlnsk-h-rbac)[orchestra/auth

Auth Component for Orchestra Platform

24108.5k3](/packages/orchestra-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
