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

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

emilmoe/guardian
================

Middleware based permission control

36[1 issues](https://github.com/EmilMoe/Guardian/issues)PHP

Since May 11Pushed 10y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Guardian
========

[](#guardian)

[![Latest Version on Packagist](https://camo.githubusercontent.com/831d81d3885ac1edb4063522be99f7d97d1f025fa2b933f7a2f58a01376abea3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f456d696c4d6f652f477561726469616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/EmilMoe/Guardian)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/16c8d963a83af41a6fc916669edb56a175b5165b5d839780f846bdc9f5d1fde9/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f456d696c4d6f652f477561726469616e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/EmilMoe/Guardian)[![Coverage Status](https://camo.githubusercontent.com/d51335469e52707fbcc1b0d8297db4cdb19e564fcfa80904f714acceaa53d5a2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f456d696c4d6f652f477561726469616e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/EmilMoe/Guardian/code-structure)[![Quality Score](https://camo.githubusercontent.com/a7914e01ec4d237a8cdf00e403d324be7a21b8aacab0c07d62ec1f04fb502c99/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f456d696c4d6f652f477561726469616e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/EmilMoe/Guardian)[![Total Downloads](https://camo.githubusercontent.com/1a6587111d133d9cd5437a1c06c8d53663f370fb1dbab92c509eebb795357689/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f456d696c4d6f652f477561726469616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/EmilMoe/Guardian)

Guardian is a framework for handling roles and permissions in Laravel. As SaaS and management web application are being more and more popular, it's essential to make the flow of the permissions as simple as possible, so you can focus on making the product.

Therefor I made this package which will enable you to define permissions in middleware. Not only does this allow you to separate the logic from your application it also allows you to perform `php artisan route:list` to see which part of your application is restricted by which permission.

Requirements
------------

[](#requirements)

Guardian requires **Laravel 5.1** in order to work due to it's use of middleware parameters. Other requirements are defined by [Laravel 5.1](https://laravel.com/docs/5.1).

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

[](#installation)

The easiest way to install Guardian is to use composer. Run this composer in your shell to begin installation

```
composer require emilmoe/guardian
```

After the package has successfully been installed to your application, you must set up a service provider in `config\app.php`:

```
EmilMoe\Guardian\GuardianServiceProvider::class,
```

Publish the migrations and configuration files to your application by executing this command in your shell:

```
php artisan vendor:publish --provider="EmilMoe\GuardianServiceProvider"
```

Please take a look through the config fil in `config\guardian.php` as some configurations must be set before you migrate the package. The configurations is sefl explainable.

Last step is to migrate 4 tables to your database. Guardian currently only supports application with an database, the tables are used to keep track of roles, permissions and how they are related between and with your application.

Run the migration by executing this in your shell:

```
php artisan migrate
```

In your user model, which by default is `App\User.php` you must add this trait:

```
use WithPermission;
```

Read more about the traits in the trait section, but it's essential for Guardian to work.

Usage
-----

[](#usage)

See

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

Coming

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Emil Moe](https://github.com/emilmoe)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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://avatars.githubusercontent.com/u/555083?v=4)[Emil Moe](/maintainers/emilmoe)[@EmilMoe](https://github.com/EmilMoe)

### Embed Badge

![Health badge](/badges/emilmoe-guardian/health.svg)

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

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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