PHPackages                             ricardoriogo/permiso - 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. ricardoriogo/permiso

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

ricardoriogo/permiso
====================

Simple Laravel 5 package to add Role-based Permissions

103183PHP

Since Apr 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/ricardoriogo/Permiso)[ Packagist](https://packagist.org/packages/ricardoriogo/permiso)[ RSS](/packages/ricardoriogo-permiso/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Permiso
=======

[](#permiso)

---

[![Build Status](https://camo.githubusercontent.com/60fc3f1a66df525c8cce6ffed9eec34203d089ac0e90d6b84f37c3cf18f11f72/68747470733a2f2f7472617669732d63692e6f72672f7269636172646f72696f676f2f5065726d69736f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ricardoriogo/Permiso)

A simple Laravel 5 package for Role-based permissions.

Instalation
-----------

[](#instalation)

### 1. Add to composer.json

[](#1-add-to-composerjson)

In the `require` key of `composer.json` file add the following:

```
"ricardoriogo/permiso": "dev-master"

```

Run composer update command.

```
$ composer update

```

### 2. Register Service Provider

[](#2-register-service-provider)

In `config/app.php` add `Riogo\Permiso\PermisoServiceProvider` to the end of `$providers` array.

```
    'providers' => array(
		'App\Providers\EventServiceProvider',
		'App\Providers\RouteServiceProvider',
        ...
        'Riogo\Permiso\PermisoServiceProvider',
    ),
```

### 3. Change Auth configuration

[](#3-change-auth-configuration)

In `config/auth.php` change the `driver` configuration to `permiso`. Permiso will use `App\User` model by default. You will need to change `model` configuration on `config/auth.php` if you're using another model for authentication.

### 4. Add UserRoleTrait to your auth model

[](#4-add-userroletrait-to-your-auth-model)

In your auth model add the **UserRoleTrait** trait. By default **App\\User** is the model used for authentication.

```
    class User extends Model implements AuthenticatableContract, CanResetPasswordContract {

        use Riogo\Permiso\UserRolesTrait
        ...
    }
```

### 5. Run Migrations

[](#5-run-migrations)

To create the migration file for roles and permissions tables use the command:

```
$ php artisan permiso:migration

```

This will create a migration file on `database/migrations`. Then use migrate command.

```
$ php artisan migrate

```

---

How to use
----------

[](#how-to-use)

Permiso extends Auth class capabilities for checking if authenticated user have especific roles or permissions.

### Checking for a Role

[](#checking-for-a-role)

To check for a role you have to use `hasRole()` method.

```
    if (Auth::hasRole('admin')) {
        // Actions for this Role
    }
```

You can use the alias method `is()` too.

```
     if (Auth::is('admin')) {
        // Actions for this Role
     }
```

### Checking for multiple Roles

[](#checking-for-multiple-roles)

It's possible check for multiple roles, passing an array with the roles or a string with comma separated values.

```
    // Using an array
    if (Auth::hasRole(['admin', 'member'])) {
        // Actions for this Roles
    }

    // Same result with string
    if (Auth::hasRole('admin, member')) {
        // Actions for this Roles
    }
```

It will return true if user have one or more of this roles.

If you want to check if user have all roles use the method `checkAll()` before `hasRole()`.

```
    // Will return true if user have admin and member roles.
    if (Auth::checkAll()->hasRole(['admin', 'member'])) {
        // Actions for this Roles
    }
```

### Checking for a Permission

[](#checking-for-a-permission)

All uses of role are applicable in permissions using `hasPermission()` ou your alias `can()`.

```
    if (Auth::hasPermission('users.list')) {
        // Actions for this Permission
    }

    if (Auth::checkAll()->can('users.delete, users.create')) {
        // Actions for this Permissions
    }
```

### Variant of `is()` method

[](#variant-of-is-method)

For check one role it's possible to use a variant of `is()`, it use a magic method to define a role to check. See the examples:

- `Auth::isAdmin()` will return true if user have **admin** role.
- `Auth::isMember()` will return true if user have **member** role.
- `Auth::isRoleWithLongName()` will return true if user have **role\_with\_long\_name** role.

---

Configuration
-------------

[](#configuration)

If you will use your own models for Role and Permission or change the default tables names, publish the configuration file using

```
$ php artisan vendor:publish --provider="Riogo\Permiso\PermisoServiceProvider"

```

And change all configuration needed in `config/permiso.php`.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2faec5e53bc31f72ba90fa7f1566b17b0557b93953e26f046c26978bd57b2125?d=identicon)[ricardoriogo](/maintainers/ricardoriogo)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/ricardoriogo-permiso/health.svg)

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

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