PHPackages                             proshore/entrust-lumen - 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. proshore/entrust-lumen

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

proshore/entrust-lumen
======================

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

1.0.3(8y ago)1128.7k↓34.2%9MITPHPPHP &gt;=5.5.0

Since Oct 9Pushed 7y ago5 watchersCompare

[ Source](https://github.com/proshore/entrust-lumen)[ Packagist](https://packagist.org/packages/proshore/entrust-lumen)[ RSS](/packages/proshore-entrust-lumen/feed)WikiDiscussions dev-entrust-lumen Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (6)Used By (0)

Forked from .
================================================

[](#forked-from-httpsgithubcomzizacoentrust)

ENTRUST (Lumen 5 Package)
=========================

[](#entrust-lumen-5-package)

[![Build Status](https://camo.githubusercontent.com/90c4762f64f0d9736533dab1f5dd1da6b5f3619242afd354325ad38a34157477/68747470733a2f2f7472617669732d63692e6f72672f70726f73686f72652f656e74727573742d6c756d656e2e7376673f6272616e63683d6465762d656e74727573742d6c756d656e)](https://travis-ci.org/proshore/entrust-lumen)[![Version](https://camo.githubusercontent.com/0ba922149f4baf6c31a7a97252cef8e2b3105c85af4a0da4fdff7ae0dec108a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f50726f73686f72652f656e74727573742d6c756d656e2e737667)](https://packagist.org/packages/proshore/entrust-lumen)[![License](https://camo.githubusercontent.com/62d8e299801afe8a999284c18a818299159515d12b82ca6b96cf0fe51569e068/68747470733a2f2f706f7365722e707567782e6f72672f70726f73686f72652f656e74727573742d6c756d656e2f6c6963656e7365)](https://packagist.org/packages/proshore/entrust-lumen)[![Total Downloads](https://camo.githubusercontent.com/aabb154597210b896d629057d1b0fd9fb35ac86567b8c2bf4b78854b7ff8ef2b/68747470733a2f2f706f7365722e707567782e6f72672f70726f73686f72652f656e74727573742d6c756d656e2f646f776e6c6f616473)](https://packagist.org/packages/proshore/entrust-lumen)

Entrust-Lumen is a Fork project modified to run with Lumen. It is a succinct and flexible way to add Role-based Permissions to **Lumen 5**.

Contents
--------

[](#contents)

- [Installation](#installation)
- [Configuration](#configuration)
    - [User relation to roles](#user-relation-to-roles)
    - [Models](#models)
        - [Role](#role)
        - [Permission](#permission)
        - [User](#user)
        - [Soft Deleting](#soft-deleting)
- [Usage](#usage)
    - [Concepts](#concepts)
        - [Checking for Roles &amp; Permissions](#checking-for-roles--permissions)
        - [User ability](#user-ability)
    - [Blade templates](#blade-templates)
    - [Middleware](#middleware)
    - [Short syntax route filter](#short-syntax-route-filter)
    - [Route filter](#route-filter)
- [Troubleshooting](#troubleshooting)
- [License](#license)
- [Contribution guidelines](#contribution-guidelines)
- [Additional information](#additional-information)

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

[](#installation)

1. In order to install Lumen 5 Entrust, just add the following to your composer.json. Then run `composer update`:

```
"proshore/entrust-lumen":"1.0.2"
```

to your composer.json. Then run `composer install` or `composer update`.

Then in your `bootstrap/app.php` add

```
    // Register Service providers for Entrust
    $app->register(Zizaco\Entrust\EntrustServiceProvider::class);
```

in the same file find the line with

```
$app->withFacades();
```

and add the facades as

```
    $app->withFacades(true,
         [
             Zizaco\Entrust\EntrustFacade::class => 'Entrust',
         ]);
```

.

If you are going to use [Middleware](#middleware) (requires Lumen 5.1 or later) you also need to add

```
    'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
    'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
    'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
```

to `$app->routeMiddleware` methods array in `bootstrap/app.php`.

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

[](#configuration)

Set the property values in the `config/auth.php`. These values will be used by entrust to refer to the correct user table and model.

You can also publish the configuration for this package to further customize table names and model namespaces.
Just use `php artisan vendor:publish` and a `entrust.php` file will be created in your app/config directory.

Note: You may need to install [lumen-vendor-publish](https://github.com/laravelista/lumen-vendor-publish) to publish the `entrust.php` file.

So that your custom configurations be integrated in your app, insert this line in your bootstrap/app.php

```
    $app->configure('permission');
```

### User relation to roles

[](#user-relation-to-roles)

Now generate the Entrust migration:

```
php artisan entrust:migration
```

It will generate the `_entrust_setup_tables.php` migration. You may now run it with the artisan migrate command:

```
php artisan migrate
```

After the migration, four new tables will be present:

- `roles` — stores role records
- `permissions` — stores permission records
- `role_user` — stores [many-to-many](http://laravel.com/docs/4.2/eloquent#many-to-many) relations between roles and users
- `permission_role` — stores [many-to-many](http://laravel.com/docs/4.2/eloquent#many-to-many) relations between roles and permissions

### Models

[](#models)

#### Role

[](#role)

Create a Role model inside `app/models/Role.php` using the following example:

```
