PHPackages                             uwla/lacl - 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. uwla/lacl

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

uwla/lacl
=========

Laravel Access Control List

v2.1.2(1y ago)624MITPHP

Since Feb 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/uwla/lacl)[ Packagist](https://packagist.org/packages/uwla/lacl)[ Docs](https://github.com/uwla/lacl)[ RSS](/packages/uwla-lacl/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (20)Used By (0)

LACL - Laravel Access Control List
==================================

[](#lacl---laravel-access-control-list)

Implementation of Access Control List System in Laravel.

The system handles authorizations of certain actions based on roles and permissions. Permissions are assigned to roles, and roles are assigned to users. If a user's role has the matching permission, then the user is authorized to perform the given action; else the user is forbidden. The permissions can be arbitrarily defined by the application developers.

The system can handle resource-based permissions, that is: a permission is associated with a resource/model/entity in the database. Thus, it is possible to, for example, define authorization for a user to edit all articles or just the articles he has created by creating permissions for those articles in particular. This is better than adding a 'user\_id' column to the articles table.

Features
--------

[](#features)

- Role-based access control list
- Per-role permission: assign permission to a role
- Per-user permission: assign permission to a user
- Per-model permission: associate a unique model in DB with a permission
- Automated Laravel Policies for controllers using per-model permissions
- Clean interface with permission-name guessing
- Arbitrary permissions
- Arbitrary roles

Demo
----

[](#demo)

A demo app is available on github at [uwla/lacl-demo](https://github.com/uwla/lacl_demo) to illustrate usage.

FAQ
---

[](#faq)

**Why should I use this package instead of popular ones, such as spatie permissions?**

This package provides some functionality that spatie's and other permission-management packages do not provide, such as per-model permission and Resource Policy automation. At the same time, their packages provide functionality that this package does not provide, such as searching permissions based on wildcards or support for team permissions. Please, read the full README to understand better what this package does and what it does not. If you should use this package or not will depend on the specific needs for your application; it is up to you as developer to figure it out.

**Why this package?**

I had specific needs that led me to develop this package and I was not aware of another package that would fit my needs at the time I started developing this package.

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

[](#installation)

Install using composer:

```
composer require uwla/lacl
```

Publish the ACL table migrations:

```
php artisan vendor:publish --provider="Uwla\Lacl\AclServiceProvider"
```

Run the migrations:

```
php artisan migrate
```

Usage
-----

[](#usage)

Convention used here:

- `User` refers to `App\Models\User`
- `Role` refers to `Uwla\Lacl\Models\Role`
- `Permission` refers to `Uwla\Lacl\Models\Permission`
- `Collection` refers to `Illuminate\Database\Eloquent\Collection`

### HasRole

[](#hasrole)

Add Traits to the application's user class:

```
