PHPackages                             joseph/rbac - 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. joseph/rbac

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

joseph/rbac
===========

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

v1.0(11y ago)228[1 issues](https://github.com/arunjoseph/Rbac/issues)MITPHPPHP &gt;=5.3.0

Since May 31Pushed 11y ago1 watchersCompare

[ Source](https://github.com/arunjoseph/Rbac)[ Packagist](https://packagist.org/packages/joseph/rbac)[ RSS](/packages/joseph-rbac/feed)WikiDiscussions master Synced 6d ago

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

Rbac (Laravel4 Package)
=======================

[](#rbac-laravel4-package)

Rbac is a copy of rbac, modded for my need, provides a flexible way to add Role-based Permissions to **Laravel4**.

### Required setup

[](#required-setup)

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

```
"joseph/rbac": "v1.0"

```

Run the Composer update comand

```
$ composer update

```

In your `config/app.php` add `'Joseph\Rbac\RbacServiceProvider'` to the end of the `$providers` array

```
'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'Joseph\Rbac\RbacServiceProvider',

),
```

At the end of `config/app.php` add `'Rbac'    => 'Joseph\Rbac\RbacFacade'` to the `$aliases` array

```
'aliases' => array(

    'App'        => 'Illuminate\Support\Facades\App',
    'Artisan'    => 'Illuminate\Support\Facades\Artisan',
    ...
    'Rbac'    => 'Joseph\Rbac\RbacFacade',

),
```

### Configuration

[](#configuration)

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

### User relation to roles

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

Now generate the Rbac migration

```
$ php artisan rbac:migration

```

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

```
$ php artisan migrate

```

After the migration, two new tables will be present: `roles` which contain the existent roles and it's permissions and `assigned_roles` which will represent the [Many-to-Many](http://four.laravel.com/docs/eloquent#many-to-many) relation between `User` and `Role`.

### Models

[](#models)

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

```
