PHPackages                             macgriog/laravel-acl - 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. macgriog/laravel-acl

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

macgriog/laravel-acl
====================

v0.0.1(8y ago)05MITPHPPHP ^7.1

Since Jan 29Pushed 8y ago1 watchersCompare

[ Source](https://github.com/macghriogair/laravel-acl)[ Packagist](https://packagist.org/packages/macgriog/laravel-acl)[ RSS](/packages/macgriog-laravel-acl/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (7)Versions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/7b8872c266cb734c3c540ab807c433e9d9e39c7a05d5bfbd05ec638d239fc6b8/68747470733a2f2f7472617669732d63692e6f72672f6d6163676872696f676169722f6c61726176656c2d61636c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/macghriogair/laravel-acl)

ACL Package for Laravel
=======================

[](#acl-package-for-laravel)

Simple access control based on User - Roles - Permissions, adapted from OctoberCMS.

How it works
------------

[](#how-it-works)

Access is granted based on a User having a specific permission.

Roles are considered sets of permissions.

A User can have permissions.

A User can have multiple roles assigned.

For a single User, all permissions get merged.

Permissions are persisted in a JSON column, e.g.

```
{"backend.read" : 1, "backend.write" : -1, "system.shutdown": 0}

```

1 = permission grantend 0 = permission not granted -1 = forcibly revoke granted permission (e.g. if was inherited from Role)

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

[](#installation)

To install via Composer, run the following command:

```
composer require macgriog/laravel-acl

```

For Laravel 5.4 and 5.3: add Service Provider
---------------------------------------------

[](#for-laravel-54-and-53-add-service-provider)

*Note: Since Laravel 5.5 the ServiceProviders are being registered automatically.*

If you are using an older version or have opted out of auto-discovery, add the following in config/app.php.

```
'providers' => [
    Macgriog\Acl\AclServiceProvider::class,
],

```

Database Migrations
-------------------

[](#database-migrations)

This package works is meant to be used along a relational database like MariaDB. It expects 2 tables: `users` and `roles`. See the [migration files](./database/migrations) for Schema details.

In a fresh Laravel install you can publish and run the necessary migrations via:

```
php artisan vendor:publish --provider="Macgriog\Acl\AclServiceProvider"
php artisan migrate

```

*Please note, that this will require the `doctrine/dbal` package to be installed. It is not added as a composer dependency, because running the migrations is completely optional, depending on your use case.*

Usage
-----

[](#usage)

### User Model

[](#user-model)

Add the Trait to your User model and define the Role relation:

```
