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

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

zainburfat/rbac
===============

This package allows you to manage user permissions and roles in a database and authentication and authorization

v1.0.12(3y ago)05MITPHP

Since Jan 3Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Zainulabdin-burfat/rbac)[ Packagist](https://packagist.org/packages/zainburfat/rbac)[ RSS](/packages/zainburfat-rbac/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

 [![Total Downloads](https://camo.githubusercontent.com/157beb7275960b0ea61ea715e2f7865146a8474a06e7d1160b3bd9d42e12fec2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f776e6c6f6164732d64656d6f2d677265656e)](https://packagist.org/packages/zainburfat/rbac) [![License](https://camo.githubusercontent.com/4a64c31c71966d152c876eea1f35e85fbd33d57ddf5754260a41f053aa72c5b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c61726176656c2f6672616d65776f726b)](https://packagist.org/packages/zainburfat/rbac)

Laravel - Role Based Access Control
===================================

[](#laravel---role-based-access-control)

##### Custom Route Wise Access Control

[](#custom-route-wise-access-control)

##### This package allows you to manage user permissions and roles in a database and Authentication and Authorization

[](#this-package-allows-you-to-manage-user-permissions-and-roles-in-a-database-and-authentication-and-authorization)

1. Custom RBAC user based roles and permissions package
2. Custom RBAC provides flexibility to use Laravel/Passport in a manner of minutes.

##### Prerequisites

[](#prerequisites)

7. Laravel ^8.0
8. Php ^7.3
9. Laravel/Passport ^10.4
##### Commands

[](#commands)

```
composer require zainburfat/rbac
```

##### Run migrations:

[](#run-migrations)

```
php artisan migrate
```

##### Install Passport:

[](#install-passport)

```
php artisan passport:install
```

##### Use trait in the "User" model:

[](#use-trait-in-the-user-model)

```
use HasApiTokens

use UserPermissionTrait
```

##### To exclude some methods/class from creating permissions of them just add "@exclude-permission" in the docs block of class/method you want to exclude.

[](#to-exclude-some-methodsclass-from-creating-permissions-of-them-just-add-exclude-permission-in-the-docs-block-of-classmethod-you-want-to-exclude)

```
/**
 *...
 *@exclude-permission
 *...
 */
class SomeController extends Controller
{
    /**
     *...
     *@exclude-permission
     *...
     */
    public function index()
    {
        ...
    }
}
```

##### Permissions are created dynamically through command according to the controllers having methods:

[](#permissions-are-created-dynamically-through-command-according-to-the-controllers-having-methods)

```
php artisan create:permission
```

##### Define an api authentication guard and set the driver option to passport in config/auth.php:

[](#define-an-api-authentication-guard-and-set-the-driver-option-to-passport-in-configauthphp)

```
'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],
```

##### Publish config file

[](#publish-config-file)

```
php artisan vendor:publish --tag=custom-rbac
```

##### Set token expirations inside config\\customrbac.php:

[](#set-token-expirations-inside-configcustomrbacphp)

```
    'tokensExpireIn' => now()->addDays(15),
    'refreshTokensExpireIn' => now()->addDays(30),
    'personalAccessTokensExpireIn' => now()->addMonths(6)
```

##### Use PermissionsApi middleware to authorize user to specific Api route and for web routes use PermissionsWeb middleware

[](#use-permissionsapi-middleware-to-authorize-user-to-specific-api-route-and-for-web-routes-use-permissionsweb-middleware)

app/http/kernel.php under protected $routeMiddleware:

```
'permissionsApi' => \Zainburfat\Rbac\Middleware\PermissionsApi::class,
'permissionsWeb' => \Zainburfat\Rbac\Middleware\PermissionsWeb::class,
```

##### Login and register using package's route

[](#login-and-register-using-packages-route)

For Login use paramenters ('email', 'passport')

For Register use paramenters ('name', 'email', 'passport')

```
http://yourdomain/rbac_login
http://yourdomain/rbac_register
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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 ~2 days

Total

4

Last Release

1217d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/597c13168952426342a4d91900967f26305d8cf8a65596c4ee291826761f1af7?d=identicon)[Zainulabdin-burfat](/maintainers/Zainulabdin-burfat)

---

Top Contributors

[![Zainulabdin-burfat](https://avatars.githubusercontent.com/u/80884412?v=4)](https://github.com/Zainulabdin-burfat "Zainulabdin-burfat (141 commits)")

---

Tags

authlaravelpermissionsphprbac

### Embed Badge

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

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

###  Alternatives

[dusterio/lumen-passport

Making Laravel Passport work with Lumen

6511.3M9](/packages/dusterio-lumen-passport)[corbosman/laravel-passport-claims

Add claims to Laravel Passport JWT Tokens

88655.9k](/packages/corbosman-laravel-passport-claims)[smartins/passport-multiauth

Add support to multi-auth on Laravel Passport

285324.2k1](/packages/smartins-passport-multiauth)[coderello/laravel-passport-social-grant

Social Grant for Laravel Passport

179607.4k3](/packages/coderello-laravel-passport-social-grant)[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

55342.3k2](/packages/jeremy379-laravel-openid-connect)[adaojunior/passport-social-grant

Social grant for Laravel Passport

116279.2k1](/packages/adaojunior-passport-social-grant)

PHPackages © 2026

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