PHPackages                             bsaleem546/roles-permissions - 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. bsaleem546/roles-permissions

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

bsaleem546/roles-permissions
============================

A Laravel package for roles and permissions management.

01PHP

Since Jul 23Pushed 9mo agoCompare

[ Source](https://github.com/bsaleem546/RolesPermissions)[ Packagist](https://packagist.org/packages/bsaleem546/roles-permissions)[ RSS](/packages/bsaleem546-roles-permissions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

RolesPermissions
================

[](#rolespermissions)

A Laravel package for advanced roles and permissions management.

Features
--------

[](#features)

- Role and permission models with many-to-many relationships
- Middleware for dynamic permission gates
- Database migrations and seeders for roles and permissions
- Easy publishing of models, migrations, seeders, and middleware into your Laravel app for customization

---

Installation &amp; Setup
------------------------

[](#installation--setup)

### 1. Require the Package

[](#1-require-the-package)

If your package is not on Packagist, add it as a local path repository in your Laravel app's `composer.json`:

```
"repositories": [
    {
        "type": "path",
        "url": "/absolute/path/to/RolesPermissions"
    }
]
```

Then require it:

```
composer require bsaleem546/roles-permissions:dev-main
```

---

### 2. Publish Package Files

[](#2-publish-package-files)

After installation, publish the package's files into your Laravel app:

```
php artisan vendor:publish --tag=roles-permissions-models
php artisan vendor:publish --tag=roles-permissions-migrations
php artisan vendor:publish --tag=roles-permissions-seeders
php artisan vendor:publish --tag=roles-permissions-middleware
```

This will copy:

- Models to `app/Models/`
- Migrations to `database/migrations/`
- Seeders to `database/seeders/`
- Middleware to `app/Http/Middleware/`

---

### 3. Run Migrations

[](#3-run-migrations)

```
php artisan migrate
```

---

### 4. Seed the Database

[](#4-seed-the-database)

```
php artisan db:seed --class=RoleSeeder
php artisan db:seed --class=PermissionSeeder
```

---

### 5. Register the Service Provider (if not auto-discovered)

[](#5-register-the-service-provider-if-not-auto-discovered)

Add to `config/app.php` in the `providers` array:

```
RolesPermissions\RolesPermissionsServiceProvider::class,
```

---

Usage
-----

[](#usage)

### Models

[](#models)

Use the published models in `app/Models/Role.php` and `app/Models/Permission.php` as you would any Eloquent model. They include all necessary relationships and constants.

### Middleware

[](#middleware)

The `AuthGateMiddleware` is published to `app/Http/Middleware/AuthGateMiddleware.php` and registered as `auth.gate` by the service provider. Use it in your routes:

```
Route::middleware(['auth.gate'])->group(function () {
    // Protected routes
});
```

### Permission Checks

[](#permission-checks)

Use Laravel's Gate system to check permissions:

```
use Illuminate\Support\Facades\Gate;

if (Gate::allows('dashboard')) {
    // User can access the dashboard
}
```

Or in Blade:

```
@can('dashboard')
    ...
@endcan
```

### Traits

[](#traits)

The package provides a trait for permission checks:

```
use RolesPermissions\Traits\HasPermissionCheck;

class SomeController extends Controller
{
    use HasPermissionCheck;

    public function someAction()
    {
        $this->checkPermissionOrAbort('dashboard');
        // ...
    }
}
```

---

Customization
-------------

[](#customization)

- Edit the published models, seeders, middleware, and migrations as needed for your application.
- Add or modify permissions and roles by updating the seeders or using Eloquent directly.

---

Updating the Package
--------------------

[](#updating-the-package)

If you update the package and want to overwrite the published files, re-run the vendor:publish commands with the `--force` flag:

```
php artisan vendor:publish --tag=roles-permissions-models
php artisan vendor:publish --tag=roles-permissions-migrations
php artisan vendor:publish --tag=roles-permissions-seeders
php artisan vendor:publish --tag=roles-permissions-middleware
```

---

License
-------

[](#license)

MIT

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance40

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0321d09fe6605c96188ef2e7148e1436cc15d23c44ff79a2cf1143bbb3a35795?d=identicon)[bsaleem546](/maintainers/bsaleem546)

---

Top Contributors

[![bsaleem546](https://avatars.githubusercontent.com/u/81158349?v=4)](https://github.com/bsaleem546 "bsaleem546 (1 commits)")

### Embed Badge

![Health badge](/badges/bsaleem546-roles-permissions/health.svg)

```
[![Health](https://phpackages.com/badges/bsaleem546-roles-permissions/health.svg)](https://phpackages.com/packages/bsaleem546-roles-permissions)
```

###  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)
