PHPackages                             njbm/role-permission - 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. njbm/role-permission

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

njbm/role-permission
====================

A simple, robust role-permission package for Laravel (one role per user).

v1.0(11mo ago)01MITPHP

Since Jul 24Pushed 11mo agoCompare

[ Source](https://github.com/njbm/role-permission)[ Packagist](https://packagist.org/packages/njbm/role-permission)[ Docs](https://github.com/njbm/role-permission)[ RSS](/packages/njbm-role-permission/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

🔐 Laravel Role-Permission Package (One Role Per User)
=====================================================

[](#-laravel-role-permission-package-one-role-per-user)

A simple, robust, and easy-to-manage Laravel role-permission system (one role per user) — **no external dependencies** like Spatie.

> Built and maintained by [Jaber Masud](http://jaber.netlify.app)

---

📦 Installation
--------------

[](#-installation)

### Option 1: Install from GitHub (Packagist style)

[](#option-1-install-from-github-packagist-style)

```
composer require njbm/role-permission
```

Update
------

[](#update)

```
composer update njbm/role-permission
```

Specific Virsion
----------------

[](#specific-virsion)

```
composer require njbm/role-permission:^1.0.1
```

Remove package
--------------

[](#remove-package)

```
composer remove njbm/role-permission
```

⚙️ Configuration
----------------

[](#️-configuration)

### Step 1: Add service provider and alias (optional for Laravel &lt; 5.5)

[](#step-1-add-service-provider-and-alias-optional-for-laravel--55)

```
// config/app.php

'providers' => [
    RolePermission\RolePermissionServiceProvider::class,
],

'aliases' => [
    'AccessControl' => RolePermission\Facades\AccessControl::class,
],
```

### Step 2: Publish the config file

[](#step-2-publish-the-config-file)

```
php artisan vendor:publish --provider="RolePermission\RolePermissionServiceProvider" --tag=config
```

### 🛠 Database Setup

[](#-database-setup)

### Step 1: Migrate Tables

[](#step-1-migrate-tables)

```
php artisan migrate
```

### Step 2: Seed Default Roles and Permissions

[](#step-2-seed-default-roles-and-permissions)

```
php artisan db:seed --class="RolePermission\Seeders\RolePermissionSeeder"
```

🔐 Seeder uses config('role-permission.default\_roles') to assign permissions to each role.

### 🧠 Model Setup

[](#-model-setup)

Add trait to your Admin or User model (must have role\_id column):

```
use RolePermission\Traits\HasPermissions;

class Admin extends Authenticatable
{
    use HasPermissions;
}
```

### ✅ Usage

[](#-usage)

Use the AccessControl facade anywhere to check permissions or roles:

```
use AccessControl;

if (AccessControl::can('edit address')) {
    // Authorized
}

if (AccessControl::role('admin')) {
    // Admin only
}
```

### 🛡 Middleware setup

[](#-middleware-setup)

Add middleware to app/Http/Kernel.php:

```
'check.permission' => \RolePermission\Middleware\CheckPermission::class,
```

Use middleware on routes:

```
'check.permission' => \RolePermission\Middleware\CheckPermission::class,
```

### 🧩 Blade directive (optional)

[](#-blade-directive-optional)

Register in AppServiceProvider:

```
Blade::if('canDo', function ($permission) {
    return \AccessControl::can($permission);
});
```

Use in Blade templates:

```
@canDo('delete address')
    Delete
@endcanDo
```

### ⚙ Example config/role-permission.php

[](#-example-configrole-permissionphp)

```
return [
    'default_roles' => [
        'admin' => [
            'edit address',
            'delete address',
            'view dashboard',
        ],
        'editor' => [
            'edit address',
        ],
    ],
];
```

### 📜 Summary

[](#-summary)

Install package via composer

Publish config and migrate database tables

Seed default roles and permissions

Add trait to your User/Admin model

Use AccessControl facade for permission checks

Protect routes with middleware

Use optional Blade directive for cleaner views

### 📄 License

[](#-license)

MIT License — created by Jaber Masud

jaber.netlify.app

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance51

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

345d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f91a1030c9a5361ddc347df4f6f9dfef431c00e0111a54b97c1006a0f4a21de6?d=identicon)[jabermasud](/maintainers/jabermasud)

---

Top Contributors

[![njbm](https://avatars.githubusercontent.com/u/126042980?v=4)](https://github.com/njbm "njbm (3 commits)")

---

Tags

permissionaccess-controlrolejabermasudnjbm

### Embed Badge

![Health badge](/badges/njbm-role-permission/health.svg)

```
[![Health](https://phpackages.com/badges/njbm-role-permission/health.svg)](https://phpackages.com/packages/njbm-role-permission)
```

###  Alternatives

[casbin/casbin

a powerful and efficient open-source access control library for php projects.

1.3k1.5M54](/packages/casbin-casbin)[casbin/laravel-authz

An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.

331368.6k4](/packages/casbin-laravel-authz)[sereny/nova-permissions

Laravel Nova - Roles &amp; Permissions

87455.9k1](/packages/sereny-nova-permissions)[casbin/think-authz

An authorization library that supports access control models like ACL, RBAC, ABAC for ThinkPHP.

27521.0k6](/packages/casbin-think-authz)[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)[itstructure/laravel-rbac

Laravel package for RBAC manage

556.9k](/packages/itstructure-laravel-rbac)

PHPackages © 2026

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