PHPackages                             thiagoprz/simple-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. thiagoprz/simple-role

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

thiagoprz/simple-role
=====================

Laravel package to add a simple role based authentication system to any project

0.0.12(1y ago)365MITPHPPHP &gt;=8.0CI failing

Since Aug 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/thiagoprz/simple-role)[ Packagist](https://packagist.org/packages/thiagoprz/simple-role)[ RSS](/packages/thiagoprz-simple-role/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (13)Used By (0)

**SimpleRole**
==============

[](#simplerole)

Package that adds a simple role based authentication system to any Laravel project.

**Installing and using**
------------------------

[](#installing-and-using)

`composer require thiagoprz/simple-role`

Run the migration that will add role column to your users table, as: `php artisan migrate`

> Add roles using Enrollable Trait

```
...
use Thiagoprz\SimpleRole\Enrollable;
...
class User ...
{
    Use Enrollable;
    ...
}

```

This trait will add setRole($role) method to the User model and you will be able to update users role with it:

`$user->setRole('admin')`

> Add roles using Laravel standard attributes

If you don't want to use the Enrollable trait you can add 'role' column to your fillable attributes on User model:

```
class User
{
    ...
    protected $fillable = [
        'name', 'email', 'password', ... , 'role',
    ];
    ...
}

```

Define the different types of role that you will be working and use the middleware to be handle on your routes as shown above:

web.php

```
// Route enrolment will be only acessible to "employee" users
Route::get('enrolment', 'EnrolmentController@index')->middleware('role:employee');

// Routes inside Admin namespace will be only acessible to users with the role "admin"
Route::namespace('Admin')->middleware(['auth', 'role:admin'])->group(function() {
...
});

// Routes inside Customer namespace will be only acessible to users with the role "customer"
Route::namespace('Customer')->middleware(['auth', 'role:customer'])->group(function() {
...
});

```

A route can require more than one role, to do that you just need to add comma separated roles.

```
// Route enrolment will be only acessible to "employee" users
Route::get('product', 'ProductController')->middleware('role:admin,manager,employee');

```

I'm aware of other packages that can do the same with more power allowing multiple roles and other stuff, but this package contains the simplest way of doing that and will allow small projects to run a simple role based with a small footprint.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance42

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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

Recently: every ~259 days

Total

12

Last Release

460d ago

PHP version history (4 changes)0.0.1PHP ^7.1.3

0.0.8PHP ^7.1.3 || ^8.1

0.0.9PHP ^7.4 || ^8.0 || ^8.1

0.0.12PHP &gt;=8.0

### Community

Maintainers

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

---

Top Contributors

[![thiagoprz](https://avatars.githubusercontent.com/u/1896302?v=4)](https://github.com/thiagoprz "thiagoprz (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thiagoprz-simple-role/health.svg)

```
[![Health](https://phpackages.com/badges/thiagoprz-simple-role/health.svg)](https://phpackages.com/packages/thiagoprz-simple-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)[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.4M43](/packages/santigarcor-laratrust)[overtrue/laravel-follow

User follow unfollow system for Laravel.

1.2k404.7k5](/packages/overtrue-laravel-follow)[codegreencreative/laravel-samlidp

Make your PHP Laravel application an Identification Provider using SAML 2.0. This package allows you to implement your own Identification Provider (idP) using the SAML 2.0 standard to be used with supporting SAML 2.0 Service Providers (SP).

263763.5k1](/packages/codegreencreative-laravel-samlidp)

PHPackages © 2026

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