PHPackages                             rockbuzz/lara-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. rockbuzz/lara-rbac

Abandoned → [https://github.com/rockbuzz/lara-rbac](/?search=https%3A%2F%2Fgithub.com%2Frockbuzz%2Flara-rbac)ArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

rockbuzz/lara-rbac
==================

Role Based Access Control per resource

0.0.4(5y ago)0232[1 PRs](https://github.com/rockbuzz/lara-rbac/pulls)MITPHPPHP &gt;=7.2

Since Mar 11Pushed 4y agoCompare

[ Source](https://github.com/rockbuzz/lara-rbac)[ Packagist](https://packagist.org/packages/rockbuzz/lara-rbac)[ RSS](/packages/rockbuzz-lara-rbac/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (6)Used By (0)

Lara RBAC
=========

[](#lara-rbac)

Role Based Access Control per resource

[![Build Status](https://camo.githubusercontent.com/d2b5509d44a664615d1cea4f7826c404ce66d704c1294e0f4e3116b7f0dac8d9/68747470733a2f2f7472617669732d63692e6f72672f726f636b62757a7a2f6c6172612d726261632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rockbuzz/lara-rbac)

Requirements
------------

[](#requirements)

PHP &gt;=7.3

Install
-------

[](#install)

```
$ composer require rockbuzz/lara-rbac
```

```
$ php artisan vendor:publish --provider="Rockbuzz\LaraRbac\ServiceProvider" --tag="migrations"

```

```
$ php artisan migrate

```

Add Rbac trait to your `User` model

```
use Rockbuzz\LaraRbac\Traits\HasRbac;
use Rockbuzz\LaraRbac\Contracts\HasRbac as RbacInterface;

class User extends Authenticatable implements RbacInterface
{
    use HasRbac;
    ...

}
```

Usage
-----

[](#usage)

### Roles

[](#roles)

#### Create role

[](#create-role)

```
$adminRole = new \Rockbuzz\LaraRbac\Models\Role;
$adminRole->name = 'admin';
$adminRole->save();

$writerRole = new \Rockbuzz\LaraRbac\Models\Role;
$writerRole->name = 'writer';
$writerRole->save();
```

#### Assign role to user

[](#assign-role-to-user)

```
$user = User::find(1);
$user->attachRole($adminRole, $resource);
```

or

```
$user->attachRole($adminRole->id, $resource);
```

or

```
$user->attachRole([$adminRole->id, $writerRole->id], $resource);
```

#### Sync roles to user

[](#sync-roles-to-user)

```
$user->syncRoles([$adminRole->id, $writerRole->id], $resource);
```

#### Revoke role from user

[](#revoke-role-from-user)

```
$user->detachRoles([$adminRole, $writerRole->id], $resource);
```

### Permissions

[](#permissions)

#### Create permission

[](#create-permission)

```
$postStore = new \Rockbuzz\LaraRbac\Models\Permission;
$postStore->name = 'post.store';
$postStore->save();

$postUpdate = new \Rockbuzz\LaraRbac\Models\Permission;
$postUpdate->name = 'post.update';
$postUpdate->save();
```

#### Assign permission to role

[](#assign-permission-to-role)

#### Assign permission to user

[](#assign-permission-to-user)

```
$user = User::find(1);
$user->attachPermission($postStore, $resource);
```

or

```
$user->attachPermission($postStore->id, $resource);
```

or

```
$user->attachPermission([$postStore->id, $postUpdate->id], $resource);
```

#### Sync permissions to user

[](#sync-permissions-to-user)

```
$user->syncPermissions([$postStore->id, $postUpdate->id], $resource);
```

#### Revoke permission from user

[](#revoke-permission-from-user)

```
$user->detachPermissions([$postStore->id, $postUpdate->id], $resource);
```

### Check user roles/permissions

[](#check-user-rolespermissions)

```
auth()->user()->hasRole('admin', $resource);
auth()->user()->hasRole('admin|writer', $resource);
auth()->user()->hasPermission('post.update', $resource);
auth()->user()->hasPermission('post.update|delete.post', $resource);
```

### Blade directive

[](#blade-directive)

Check for role

```
@hasrole('admin', $resource)
    // ok
@else
    // no
@endrole

```

Check for permission

```
@haspermission('post.store|post.update', $resource)
    // ok
@else
    // no
@endpermission

```

License
-------

[](#license)

The Lara RBAC is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.9% 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 ~89 days

Total

4

Last Release

1981d ago

PHP version history (2 changes)0.0.1PHP ^7.3

0.0.4PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9a5c02aa268a45e5f1d9c67c331503d326eb4b49eb0fb80293dc7379ccef51f7?d=identicon)[rockbuzz](/maintainers/rockbuzz)

---

Top Contributors

[![tiagodevweb](https://avatars.githubusercontent.com/u/15040375?v=4)](https://github.com/tiagodevweb "tiagodevweb (22 commits)")[![rockbuzz-dev](https://avatars.githubusercontent.com/u/48301419?v=4)](https://github.com/rockbuzz-dev "rockbuzz-dev (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

rolespermissionsrbacrbac per resource

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/rockbuzz-lara-rbac/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.4M42](/packages/santigarcor-laratrust)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6712.1k2](/packages/hasinhayder-tyro)[smarch/watchtower

Front-end for the Shinboi Auth system of Users / Roles / Permissions in Laravel 5

523.0k](/packages/smarch-watchtower)[wnikk/laravel-access-rules

Simple system of ACR (access control rules) for Laravel, with roles, groups, unlimited inheritance and possibility of multiplayer use.

103.6k1](/packages/wnikk-laravel-access-rules)

PHPackages © 2026

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