PHPackages                             faruque-ashad/multi\_guard\_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. faruque-ashad/multi\_guard\_role\_permission

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

faruque-ashad/multi\_guard\_role\_permission
============================================

Multi-guard role permission system for managing role permissions for users.

1.1.0(1y ago)4780MITPHPPHP &gt;=8.0

Since Nov 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Faruque5698/MultiGuardRolePermission)[ Packagist](https://packagist.org/packages/faruque-ashad/multi_guard_role_permission)[ RSS](/packages/faruque-ashad-multi-guard-role-permission/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

multi-guard-role-permission
===========================

[](#multi-guard-role-permission)

Table of Contents
-----------------

[](#table-of-contents)

- [Description](#description)
- [Installation](#installation)

Description
-----------

[](#description)

**Multi Guard Role Permission** is a powerful Laravel package designed to provide a flexible and secure access control system. With this package, you can define user roles with detailed permissions and even customize permissions at the individual user level, going beyond the limitations of predefined roles. It’s an intuitive solution to strengthen access control and enhance security within your Laravel project.

Installation
------------

[](#installation)

👉 To install this package, you'll need to have Laravel version 9 or higher and PHP version 8.0.0 or higher installed on your machine. You can download the latest version of PHP from the official PHP resource: . Ensure your environment meets these requirements before proceeding with the installation.

- Install auth package in laravel project (JWT, laravel/ui etc).
- Install package: `composer require faruque-ashad/multi_guard_role_permission`
- Run migrate command: `php artisan migrate`
- Add auth guards: `php artisan add:auth {guard name}`
- After add auth guard, hit `applicatoin_url/guards` get api for guard list. `GET`  or use bellow route

    ```
      use FaruqueAshad\MultiGuardRolePermission\Http\Controllers\RolePermissionController;
      use Symfony\Component\HttpFoundation\Response;

      // auth guards
      Route::get('/guards', function () {
          return sendResponse(
              'Data fetch successfully.',
              \FaruqueAshad\MultiGuardRolePermission\Models\AuthGuard::all(),
              Response::HTTP_OK
          );
      })->name('guards');

    ```

    Resonse:

    ```
    {
     "code": 200,
     "success": true,
     "message": "Data fetch successfully.",
     "data": [
         {
             "id": 1,
             "name": "admin",
             "created_at": "2023-10-12T08:27:57.000000Z",
             "updated_at": "2023-10-12T08:27:57.000000Z",
         },
         {
             "id": 2,
             "name": "customer",
             "created_at": "2023-10-12T08:27:51.000000Z",
             "updated_at": "2023-10-12T08:27:51.000000Z",
         }
      ],
     "errors": []
     }
    ```
- Follow bellow route middleware pattern for permissions. User must be login for access the routes.

    ```
    Route::middleware('check.auth:{your-guard}')->group(function () {
    // users can access this block routes after login
      Route::middleware('permission:{your-guard}')->group(function () {
      // user can access this block routes if user logged in and if user have permission
          // demo route
          Route::group(['prefix' => 'test', 'as' => 'test.'], function () {
              Route::get('/index', function () {
                return response()->json([
                   'code' => 200,
                   'success' => true,
                   'message' => 'Permission testing',
                   'data' => [],
                   'errors' => []
                ]);
              })->name('index');
            });
      });
    });
    ```
- Suppose you have two `auth guards` like `admin` and `customer`. Then you can use bellow route pattern for permission.

    - For admin.

    ```
      Route::middleware('check.auth:admin')->group(function () {
      // users can access this block routes after login
          Route::middleware('permission:admin')->group(function () {
          // user can access this block routes if user logged in and if user have permission
            // demo routes
            Route::group(['prefix' => 'test', 'as' => 'test.'], function () {
              Route::get('/admin/dashboard', function () {
                return response()->json([
                   'code' => 200,
                   'success' => true,
                   'message' => 'Admin Permission testing',
                   'data' => [],
                   'errors' => []
                ]);
              })->name('admin.dashboard');
            });
        });
      });
    ```

    - For customer

    ```
      Route::middleware('check.auth:customer')->group(function () {
      // users can access this block routes after login
        Route::middleware('permission:customer')->group(function () {
        // user can access this block routes if user loggedin and if user have permission
            // demo routes
            Route::group(['prefix' => 'test', 'as' => 'test.'], function () {
              Route::get('/profile', function () {
                return response()->json([
                   'code' => 200,
                   'success' => true,
                   'message' => 'Customer Permission testing',
                   'data' => [],
                   'errors' => []
                ]);
              })->name('customer.profile');
            });
        });
      });
    ```
- For guard wise route permission list use bellow route.

    ```
      use FaruqueAshad\MultiGuardRolePermission\Http\Controllers\RolePermissionController;
      Route::get('permission/module/{guard}', [RolePermissionController::class, 'module_permission'])->name('permission.route.list');
    ```

    ```
    {
      "code": 200,
      "success": true,
      "message": "Data fetch successfully.",
      "data": [
           {
           "module": "test",
           "permission": [
                {
                    "auth_guard_id": 0,
                    "role_id": 0,
                    "auth_user_id": 0,
                    "module": "test",
                    "operation": " a",
                    "route": "test/a",
                    "is_permit": 0,
                    "route_name": "test.a",
                    "method": "GET"
                },
                {
                    "auth_guard_id": 0,
                    "role_id": 0,
                    "auth_user_id": 0,
                    "module": "test",
                    "operation": " b",
                    "route": "test/b",
                    "is_permit": 0,
                    "route_name": "test.b",
                    "method": "GET"
                }
              ]
          }
       ],
      "errors": []
      }
    ```
- Role CRUD route

    ```
    use FaruqueAshad\MultiGuardRolePermission\Http\Controllers\RolePermissionController;
    Route::group(['prefix' => 'role', 'as' => 'role.'], function () {
      // use `guard` params for gurad wise role list
      // use `search` params for search role
      Route::get('/list', [RolePermissionController::class, 'index'])->name('list');
      Route::post('/create', [RolePermissionController::class, 'store'])->name('create');
      Route::get('/show/{id}', [RolePermissionController::class, 'show'])->name('show');
      Route::put('/update/{id}', [RolePermissionController::class, 'update'])->name('update');
      Route::delete('/delete/{id}', [RolePermissionController::class, 'destroy'])->name('delete');
    });
    ```

    ```
    // example: Request data for role create and update
    {
      "auth_guard_id" : 1, // from '{base_url}/gurds'  api.
      "name" : "admin",
      "is_admin" : 0, // 1 means admin role and 0 means other role. If admin then there is no permission for this role.
      "role_permissions" : [ // permission data from '{base_url}/permission/{guard}' api.
          {
           "module": "test",
           "permission": [
                  {
                      "auth_guard_id": 0,
                      "role_id": 0,
                      "auth_user_id": 0,
                      "module": "test",
                      "operation": " a",
                      "route": "test/a",
                      "is_permit": 1, // 1 means add permission for test.a route
                      "route_name": "test.a",
                      "method": "GET"
                  },
                  {
                      "auth_guard_id": 0,
                      "role_id": 0,
                      "auth_user_id": 0,
                      "module": "test",
                      "operation": " b",
                      "route": "test/b",
                      "is_permit": 0, // 0 means permission not added
                      "route_name": "test.b",
                      "method": "GET"
                  }
              ]
          }
      ]
    }
    ```
- user permission list from bellow route

    ```
     use FaruqueAshad\MultiGuardRolePermission\Http\Controllers\RolePermissionController;
     Route::post('/user/permission/list', [RolePermissionController::class, 'get_user_permission_list'])->name('user.permission.list');
    ```

    ```
    // example: Request data
    {
      "auth_user_id" : 1, // your user id
      "role_id" : 1
    }
    ```
- Assaign user permission using bellow route

    ```
     use FaruqueAshad\MultiGuardRolePermission\Http\Controllers\RolePermissionController;
     Route::post('/user/permission/add', [RolePermissionController::class, 'user_permission'])->name('user.permission.add');
    ```

    ```
    // example: Request data
    {
      "auth_user_id" : 1, // your user id
      "role_id" : 2,
      "role_permissions" : [ // permission data from 'user/permission/list' api.
          {
           "module": "test",
           "permission": [
                  {
                      "auth_guard_id": 0,
                      "role_id": 0,
                      "auth_user_id": 0,
                      "module": "test",
                      "operation": " a",
                      "route": "test/a",
                      "is_permit": 1, // 1 means permission added
                      "route_name": "test.a",
                      "method": "GET"
                  },
                  {
                      "auth_guard_id": 0,
                      "role_id": 0,
                      "auth_user_id": 0,
                      "module": "test",
                      "operation": " b",
                      "route": "test/b",
                      "is_permit": 0, // 0 means permission not added
                      "route_name": "test.b",
                      "method": "GET"
                  }
              ]
          }
      ]
    }
    ```
- For user role use `userRole($guard_name, $user_id)` function .

    ```
       // response like bellow
      {
        "role_id": 1,
        "role: "Admin",
        "is_admin": 1
      }
    ```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

552d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/faruque-ashad-multi-guard-role-permission/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[stechstudio/laravel-jwt

Helper package that makes it easy to generate, consume, and protect routes with JWT tokens in Laravel

126117.6k](/packages/stechstudio-laravel-jwt)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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