PHPackages                             matthc/privileges - 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. matthc/privileges

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

matthc/privileges
=================

Small Role-Permission integration for laravel

0.2.0(10y ago)2731MITPHPPHP &gt;=5.5.9

Since Jan 9Pushed 10y agoCompare

[ Source](https://github.com/Matth--/privileges)[ Packagist](https://packagist.org/packages/matthc/privileges)[ Docs](https://github.com/MatthC)[ RSS](/packages/matthc-privileges/feed)WikiDiscussions master Synced 2mo ago

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

\#Privileges

[![SensioLabsInsight](https://camo.githubusercontent.com/299a0855c2c3f39412f4d0f41e4c20911339117db492ab2f1fbd33cd8ddc5c14/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33376465643364622d623265632d343035622d623936362d3564346238336664633166612f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/37ded3db-b2ec-405b-b966-5d4b83fdc1fa)

This is a small role-permission integration for laravel projects. I know Entrust exists but i wanted to try it myself.

\##Installation Download the package into the vendor folder

```
composer require matthc/privileges

```

Add the Service Provider to config/app.php

```
...
MatthC\Privileges\PrivilegeServiceProvider::class,
...
```

publish files

```
$ php artisan vendor:publish

```

Run the migrations

```
$ php artisan migrate

```

Adjust the settings in config/privileges.php and run the following commands to add the roles and permissions you want.

```
$ php artisan privileges:db:seed

```

If you want to add users with specific roles, run the following command:

```
$ php artisan privileges:db:users

```

Add the trait to the usermodel

```
use MatthC\Privileges\Traits\PrivilegeUserTrait;

class User extends Authenticatable
{
    use PrivilegeUserTrait;

    ...
}
```

\##Usage

\###User has role To check if a user has a specific role:

```
//one role
$user->hasRole('admin'); //returns true/false

//multiple roles
$user->hasRole(['admin', 'author']); //returns true if the user has one of these roles

//user must have all roles
$user->hasRole(['admin', 'author'], true);
```

\###User has permission To check if a user has a specific permission:

```
//one permission
$user->can('create_post');

//multiple permissions
$user->can(['create_post', 'update_post']);

//all true
$user->can(['create_post', 'update_post'], true);
```

\##Middleware You can also use predefined middleware. Add the following lines to the route middleware array in app/Http/kernel.php

```
protected $routeMiddleware = [
        ...
        'role' => \MatthC\Privileges\Middleware\PrivilegeRoleMiddleware::class,
        'permission' => \MatthC\Privileges\Middleware\PrivilegePermissionMiddleware::class,
    ];
```

Example usage:

```
Route::group(['middleware' => ['role:admin']], function() {
    //add routes
});
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

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

Total

5

Last Release

3652d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/687fe6f7f3d32b31c3fe28e86defa71d1461c5f83eaaffa60164f947468f4ecc?d=identicon)[matth--](/maintainers/matth--)

---

Top Contributors

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

---

Tags

laravelrolespermissions

### Embed Badge

![Health badge](/badges/matthc-privileges/health.svg)

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

###  Alternatives

[jeremykenedy/laravel-roles

A Powerful package for handling roles and permissions in Laravel. Supports Laravel 5.3 up to 12.

1.0k826.8k7](/packages/jeremykenedy-laravel-roles)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6712.1k2](/packages/hasinhayder-tyro)[beatswitch/lock-laravel

A Laravel Driver for Lock.

15529.1k1](/packages/beatswitch-lock-laravel)[erag/laravel-role-permission

A simple and easy-to-install role and permission management package for Laravel, supporting versions 10.x and 11.x

404.2k](/packages/erag-laravel-role-permission)

PHPackages © 2026

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