PHPackages                             buglock/rolepermissionmodule - 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. buglock/rolepermissionmodule

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

buglock/rolepermissionmodule
============================

A Role and Permission manement module

v1.0.2(11mo ago)09MITPHP

Since Jun 6Pushed 10mo agoCompare

[ Source](https://github.com/ridipblog/buglocks)[ Packagist](https://packagist.org/packages/buglock/rolepermissionmodule)[ RSS](/packages/buglock-rolepermissionmodule/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

BugLocks - Role &amp; Permission Management for Laravel
=======================================================

[](#buglocks---role--permission-management-for-laravel)

BugLocks is a modular Laravel package to manage user roles and permissions. It includes ready-to-use views, blade directives, route protection, middleware integration, and publishing support for easy customization.

---

📘 What is BugLocks?
-------------------

[](#-what-is-buglocks)

BugLocks is a powerful Laravel package designed for Role &amp; Permission management. It provides built-in UI, blade directives, database migrations, and middleware to simplify access control in Laravel applications.

---

🚀 Features
----------

[](#-features)

- **Access Control**: Secure your routes, pages, and actions using roles, permissions, and middleware.
- **Simple DB Structure**: Built-in tables for users, roles, and permissions ready for immediate use.
- **UI Ready**: Includes customizable views for login, error pages, and permission management.

---

🛠 Built With
------------

[](#-built-with)

- Laravel 9 / 10
- PHP 8+
- Bootstrap 5.3

---

🔧 Installation
--------------

[](#-installation)

### Step 1: Requirements

[](#step-1-requirements)

- ✅ PHP 8.1 or above
- ✅ Laravel 10+
- ✅ Composer installed globally
- ✅ MySQL/PostgreSQL setup

### Step 2: Install via Composer

[](#step-2-install-via-composer)

```
composer require buglock/rolepermissionmodule
```

### Step 3: Publish Config, Model &amp; Views

[](#step-3-publish-config-model--views)

```
php artisan vendor:publish --tag=buglocks-config
php artisan vendor:publish --tag=role-permissions-models
php artisan vendor:publish --tag=buglocks-error-views
```

### Step 4: Run Migrations

[](#step-4-run-migrations)

```
php artisan migrate
```

### Step 5: Optional Configuration

[](#step-5-optional-configuration)

Edit the config file at:

```
config/buglocks.php
```

---

🔐 Role &amp; Permission Management
----------------------------------

[](#-role--permission-management)

### Initialize BugLock

[](#initialize-buglock)

```
use BugLock\rolePermissionModule\Http\Controllers\BugLock;
$bugLock = new BugLock();
```

### Create Roles

[](#create-roles)

```
$bugLock->createRole('admin');
$bugLock->createRole('admin', 'editor', 'user');
```

### Create Permissions

[](#create-permissions)

```
$bugLock->createPermission('edit');
$bugLock->createPermission('edit', 'view');
```

---

🔗 Auto &amp; Manual Role-Permission Assignment
----------------------------------------------

[](#-auto--manual-role-permission-assignment)

### Auto Assignment

[](#auto-assignment)

```
$bug_lock = new BugLock();
$bug_lock->createRole('admin-1', 'admin-2');
$bug_lock->createPermission('edit-resume-1', 'remove-resume-2');
$bug_lock->assignedLocks();
dd($bug_lock);
```

### Manual Assignment

[](#manual-assignment)

```
$bug_lock = new BugLock();
$bug_lock->createRole('admin-1', 'admin-2');
$bug_lock->createPermission('edit-resume-1', 'remove-resume-2');
$bug_lock->assignedLocks(
    ['Admin'],
    ['delete','invite']
);
dd($bug_lock);
```

### Configure User Model

[](#configure-user-model)

```
namespace App\Models;

use BugLock\rolePermissionModule\Models\UserRoles;
use BugLock\rolePermissionModule\traits\assignBugLock;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable {
    use assignBugLock;
}
```

### Assign Role to User

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

```
$user = User::where('name','coder 1')->first();
$user->assignRoleToUser('admin');
$user->assignRoleToUser('manager');
if($user->fails){
    dd($user->reason);
}
```

---

🧩 Authentication Middleware
---------------------------

[](#-authentication-middleware)

### 1. Check Login

[](#1-check-login)

```
Route::group(['middleware' => ['buglock.auth:web,view,no']], function () {
    Route::get('/dash-1', [TestController::class, 'dash_1']);
});

Route::group(['middleware' => ['buglock.auth:web,view,yes']], function () {
    Route::get('/dash-1', [TestController::class, 'dash_1']);
});
```

### 2. Check Role

[](#2-check-role)

```
Route::group(['middleware' => ['buglock.role:web,view,admin,employee']], function () {
    Route::get('/dash', [TestController::class, 'dash']);
});

Route::group(['middleware' => ['buglock.role:web,view,manager']], function () {
    Route::get('/dash', [TestController::class, 'dash']);
});
```

### 3. Check Permission

[](#3-check-permission)

```
Route::group(['middleware' => ['buglock.permission:web,view,edit,delete']], function () {
    Route::get('/dash-3', [TestController::class, 'dash_3']);
});

Route::group(['middleware' => ['buglock.permission:web,view,view']], function () {
    Route::get('/dash-3', [TestController::class, 'dash_3']);
});
```

---

🧩 Blade Views
-------------

[](#-blade-views)

The package includes 3 blade templates for error handling. Customize them by publishing the views:

### View Files

[](#view-files)

- **🔒 auth.blade.php** - Shown when the user is not logged in.
- **🧑‍💼 role.blade.php** - Shown when the user does not have the required role.
- **🔑 permissions.blade.php** - Shown when the user lacks required permission.

### Publish Views

[](#publish-views)

```
php artisan vendor:publish --tag=buglocks-error-views
```

After publishing, customize in:

```
resources/views/vendor/buglock/

```

---

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance52

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

Total

3

Last Release

343d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d0f72b99025830f950f221a64c05d7bf2574f918569226a1fc86eeec34414f4?d=identicon)[debug404](/maintainers/debug404)

---

Top Contributors

[![ridipblog](https://avatars.githubusercontent.com/u/83365493?v=4)](https://github.com/ridipblog "ridipblog (6 commits)")

### Embed Badge

![Health badge](/badges/buglock-rolepermissionmodule/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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