PHPackages                             merodiro/simple-roles - 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. [Admin Panels](/categories/admin)
4. /
5. merodiro/simple-roles

ActiveLibrary[Admin Panels](/categories/admin)

merodiro/simple-roles
=====================

Simple laravel roles

v1.0(8y ago)05MITPHPPHP ~7.0CI failing

Since Dec 23Pushed 8y agoCompare

[ Source](https://github.com/merodiro/simple-roles)[ Packagist](https://packagist.org/packages/merodiro/simple-roles)[ Docs](https://github.com/merodiro/simple-admin)[ RSS](/packages/merodiro-simple-roles/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

SimpleRoles
===========

[](#simpleroles)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f12fd97131631e4af167e6715ae64b5debdb2722aeb192308fec14aefb50518d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d65726f6469726f2f73696d706c652d726f6c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/merodiro/simple-roles)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/7e55147973057f733cfac3acd1f85be2b4ac64fd679e0d199a69ee871b47a886/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d65726f6469726f2f73696d706c652d726f6c65732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/merodiro/simple-roles)[![Coverage Status](https://camo.githubusercontent.com/b89d9212bd48b757e54af5ce1f1f01969bdb2ec071b5111dd6382becfccbe43a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6d65726f6469726f2f73696d706c652d726f6c65732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/merodiro/simple-roles/code-structure)[![Quality Score](https://camo.githubusercontent.com/5c05e4b2b7f2ff56d242a30eeac328565803d4a1e1f92946ec8a7f3d99d19c76/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d65726f6469726f2f73696d706c652d726f6c65732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/merodiro/simple-roles)[![Total Downloads](https://camo.githubusercontent.com/eb5ad1fbbdcc37b7fff0e09dd0d43a3d446f9785a54fa882bb22b19cc45faf84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d65726f6469726f2f73696d706c652d726f6c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/merodiro/simple-roles)

SimpleRoles is a simple way to have roles in your laravel projects.

[![preview](/preview.png)](/preview.png)

Installation
------------

[](#installation)

Via Composer

```
$ composer require merodiro/simple-roles
```

Run the command to publish the package migration

```
php artisan vendor:publish --provider="Merodiro\SimpleRoles\SimpleRolesServiceProvider"
```

Migrate database

It assumes that users are in the `users` table, if not you can change the config file

```
php artisan migrate
```

add middleware in `app/Http/Kernel.php`

```
protected $routeMiddleware = [
    ...
    'role'      => \Merodiro\SimpleRoles\Middleware\RoleMiddleware::class,
];
```

Usage
-----

[](#usage)

add roles to `roles` array in simple-roles config file first

### Set Role

[](#set-role)

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

### Remove Role

[](#remove-role)

```
$user->removeRole();
```

### Has Role

[](#has-role)

```
if($user->hasRole('admin')){
    // do something
}
```

### Blade Templates

[](#blade-templates)

to show content to admins only

```
@role('admin')
    this is visible to admins only
@endrole
```

to show different content to admins and non-admins users

```
@role('admin')
    this is visible to admins only
@else
    this is visible to non admins only
@endrole
```

### middleware

[](#middleware)

you can use middleware to limit accessing a certain route to admins only

```
Route::get('/admin', function () {
    ...
})->middleware('role:admin');
```

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Amr A. Mohammed](https://github.com/merodiro)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

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

Total

3

Last Release

2951d ago

Major Versions

v0.2 → v1.02018-04-10

### Community

Maintainers

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

---

Top Contributors

[![merodiro](https://avatars.githubusercontent.com/u/17033502?v=4)](https://github.com/merodiro "merodiro (14 commits)")

---

Tags

laraveladminMerodiroSimpleRoles

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/merodiro-simple-roles/health.svg)

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

###  Alternatives

[slowlyo/owl-admin

基于 laravel、amis 开发的后台框架~

61214.2k26](/packages/slowlyo-owl-admin)[sebastienheyd/boilerplate

Laravel Boilerplate based on AdminLTE 3 with blade components, user management, roles, permissions, logs viewer, ...

28618.2k3](/packages/sebastienheyd-boilerplate)[lokielse/laravel-admin-generator

An Admin Panel Generator for Laravel 5

712.0k](/packages/lokielse-laravel-admin-generator)[serverfireteam/blog

A nice blog system with laravel and laravelpanel

523.1k](/packages/serverfireteam-blog)

PHPackages © 2026

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