PHPackages                             usm4n/guardian - 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. usm4n/guardian

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

usm4n/guardian
==============

Role Based Access Control Package For Laravel With Backend Interface

171.1k7PHP

Since Feb 17Pushed 11y ago4 watchersCompare

[ Source](https://github.com/usm4n/guardian)[ Packagist](https://packagist.org/packages/usm4n/guardian)[ RSS](/packages/usm4n-guardian/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

\##Guardian: Role Based Access Control Package For Laravel 5 and 4 With Backend Interface

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3e60355dfae8373a284c4d9da0ad98991597aca7e164996f460d6a11af4da456/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f75736d346e2f677561726469616e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/usm4n/guardian/?branch=master)[![Build Status](https://camo.githubusercontent.com/2e5fffa0b6956cc34cf3bf1ee59792e80475957ddacadd69642e537d707cefab/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f75736d346e2f677561726469616e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/usm4n/guardian/build-status/master)[![Latest Stable Version](https://camo.githubusercontent.com/a8b67d4a90bfdc591224e5f67e55d1c496ecf6316ca94d7f674603ed218a0002/68747470733a2f2f706f7365722e707567782e6f72672f75736d346e2f677561726469616e2f762f737461626c652e737667)](https://packagist.org/packages/usm4n/guardian)[![Total Downloads](https://camo.githubusercontent.com/9696f6403e4e0fea7d990bf8231b31c8f35cd08c24ddce00201983e4705ffe1c/68747470733a2f2f706f7365722e707567782e6f72672f75736d346e2f677561726469616e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/usm4n/guardian)[![Latest Unstable Version](https://camo.githubusercontent.com/01bdad8987133c9908007e287a030cbe5e13a3019d97ed12681df7b873e5d598/68747470733a2f2f706f7365722e707567782e6f72672f75736d346e2f677561726469616e2f762f756e737461626c652e737667)](https://packagist.org/packages/usm4n/guardian) [![License](https://camo.githubusercontent.com/86c4f2581eb62070389a7a3aa0f81037dfce8c5c8a7a0d7a25be2a2b7c927619/68747470733a2f2f706f7365722e707567782e6f72672f75736d346e2f677561726469616e2f6c6963656e73652e737667)](https://packagist.org/packages/usm4n/guardian)

\###For Laravel 4 please switch to the [old branch](https://github.com/usm4n/guardian/tree/old) .

Guardian package for Laravel provides an easy interface to manage Role Based Access Control. Through its minimalist interface you can add users, roles and capabilities. Each user can be assigned multiple roles (many to many) and each role can be assigned multiple capabilities.

Guardian also comes with plenty of Access Control helper methods that make it easy to track access for a specific user inside your code.

[![Edit Role](./screenshots/main-scr.png)](./screenshots/main-scr.png)

\##Installation and Setup

To install guardian, add the following lines in your `composer.json` file:

```
"require-dev": {
	"usm4n/guardian": "dev-master"
}

```

After adding the above lines, save the file and run:

```
composer update --dev

```

After the successful completion of the composer installation process, add the following line to the `providers` array inside the `app/config/app.php` file:

```
'Usman\Guardian\GuardianServiceProvider'

```

> If you have not already installed the `illuminate/html` package, then you will need to add the `Illuminate\Html\HtmlServiceProvider` into the `providers` array as well.

\###Running Package Migrations

To setup the database for the guardian, you will need to run the following commands to run the package migration files:

```
artisan vendor:publish --provider="Usman\Guardian\GuardianServiceProvider" --tag="guardian-migrations"

artisan migrate

```

The first command will copy the package migration files into your installation's `database/migrations` directory. You can make your custom changes to any table before running the second command.

\###Publishing View and Assets

Run the following `artisan` commands to publish the package assets and views into `public` and `resources/views` directory respectively.

```
artisan vendor:publish --provider="Usman\Guardian\GuardianServiceProvider" --tag="guardian-assets"
artisan vendor:publish --provider="Usman\Guardian\GuardianServiceProvider" --tag="guardian-views"

```

\###Model Setup

Guardian requires you to have the following models inside your `app` directory: `User`, `Role` and `Capability`.

app/Role.php

```
