PHPackages                             dasperg/laravel-role - 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. dasperg/laravel-role

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

dasperg/laravel-role
====================

Laravel 5.7 native User Authentication + Role Authorization

1.1.0(7y ago)051MITPHP

Since Mar 12Pushed 7y ago2 watchersCompare

[ Source](https://github.com/dasperg/laravel-role)[ Packagist](https://packagist.org/packages/dasperg/laravel-role)[ Docs](https://github.com/dasperg/laravel-role)[ RSS](/packages/dasperg-laravel-role/feed)WikiDiscussions master Synced today

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

Laravel simple role handling &amp; middleware
=============================================

[](#laravel-simple-role-handling--middleware)

- [Installation](#installation)
- [Usage](#usage)
- [Seeding (optional)](#seeding-optional)

Installation:
-------------

[](#installation)

This package can be used in Laravel 5.7 or higher.

You can install the package via composer:

```
composer require dasperg/laravel-role
```

Create the role tables by running the migrations:

```
php artisan migrate
```

Add RoleTrait to your `User` model:

```
use Dasperg\Role\RoleTrait;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use RoleTrait;

    // ...
}
```

Register middleware in `app/Http/Kernel.php` file:

```
protected $routeMiddleware = [
    // ...
    'role' => Dasperg/Role/RoleMiddleware::class,
];
```

Usage
-----

[](#usage)

Controller:

```
class HomeController extends Controller
{
    public function __construct()
    {
        $this->middleware('role:admin');
//        $this->middleware('role:admin,editor');   // example for multiple roles
    }
    ...
```

Route:

```
Route::get('/', 'HomeController@index')->middleware('role:admin');
```

Seeding (optional)
------------------

[](#seeding-optional)

You can publish example seeder:

```
php artisan vendor:publish --provider="Dasperg\Role\RoleServiceProvider" --tag="seeds"
```

Don't forget to dump autoloader:

```
composer dump-autoload
```

Now you can seed data:

```
php artisan db:seed --class=RolesTableSeeder
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

2

Last Release

2613d ago

### Community

Maintainers

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

---

Top Contributors

[![dasperg](https://avatars.githubusercontent.com/u/4030824?v=4)](https://github.com/dasperg "dasperg (11 commits)")

---

Tags

laravelroledasper

### Embed Badge

![Health badge](/badges/dasperg-laravel-role/health.svg)

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

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[sereny/nova-permissions

Laravel Nova - Roles &amp; Permissions

86388.6k1](/packages/sereny-nova-permissions)[klaravel/ntrust

Role-Based Permissions for Laravel 5.3+

10126.7k1](/packages/klaravel-ntrust)[itstructure/laravel-rbac

Laravel package for RBAC manage

566.6k](/packages/itstructure-laravel-rbac)[dlnsk/h-rbac

Based on native Laravel's gates and policies. Hierarchical RBAC with callbacks.

378.3k](/packages/dlnsk-h-rbac)

PHPackages © 2026

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