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

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

spekkionu/laravel-zend-acl
==========================

Adds ACL to Laravel via Laminas\\Permissions\\Acl component.

v8.0.0(3y ago)4281.9k↓32.9%9[1 issues](https://github.com/spekkionu/laravel-zend-acl/issues)MITPHPPHP &gt;=8.0

Since Oct 8Pushed 3y ago4 watchersCompare

[ Source](https://github.com/spekkionu/laravel-zend-acl)[ Packagist](https://packagist.org/packages/spekkionu/laravel-zend-acl)[ RSS](/packages/spekkionu-laravel-zend-acl/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (23)Used By (0)

Laravel Zend Acl
================

[](#laravel-zend-acl)

[![Latest Stable Version](https://camo.githubusercontent.com/5938855c521300ff5733d3e3ab8c88802b7c67c78db6cfa1f4beb4b53d3d7f61/68747470733a2f2f706f7365722e707567782e6f72672f7370656b6b696f6e752f6c61726176656c2d7a656e642d61636c2f762f737461626c652e706e67)](https://packagist.org/packages/spekkionu/laravel-zend-acl)[![Total Downloads](https://camo.githubusercontent.com/4b24a15a0ee26cfd6417e90d5228ce4bed263514c4819a0ff5c3b7fe938291c3/68747470733a2f2f706f7365722e707567782e6f72672f7370656b6b696f6e752f6c61726176656c2d7a656e642d61636c2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/spekkionu/laravel-zend-acl)[![Build Status](https://camo.githubusercontent.com/2e69cead68b264f2c1d28db3b7ea75bf8bdac09877eed1cda0fc36fe898e92a5/68747470733a2f2f7472617669732d63692e6f72672f7370656b6b696f6e752f6c61726176656c2d7a656e642d61636c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/spekkionu/laravel-zend-acl)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/c7de181f16b263b0258238f4f04599c22a7e679fca603a201f6ff69bd8a77651/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370656b6b696f6e752f6c61726176656c2d7a656e642d61636c2f6261646765732f7175616c6974792d73636f72652e706e673f733d34306331333264376532356132383536623833333139356233653838313436336330346530376439)](https://scrutinizer-ci.com/g/spekkionu/laravel-zend-acl/)[![SensioLabsInsight](https://camo.githubusercontent.com/5e3d06b1e541f6a87f55f2561e8b744248dc63df180367ee1c3e117cbd4f2b3f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f39643162376166362d326262302d343462622d626466632d3536343764633234643537612f6d696e692e706e67)](https://insight.sensiolabs.com/projects/9d1b7af6-2bb0-44bb-bdfc-5647dc24d57a)[![Code Coverage](https://camo.githubusercontent.com/533ca7f968eaaa4dde1e39c75b043cc60926992419e167f9607dc19d1523ccff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370656b6b696f6e752f6c61726176656c2d7a656e642d61636c2f6261646765732f636f7665726167652e706e673f733d63616332643330396330663961353463373565666331383261623362613033653136363035623162)](https://scrutinizer-ci.com/g/spekkionu/laravel-zend-acl/)

Adds ACL to Laravel 5 or Lumen via Laminas\\Permissions\\Acl component.

Most of the ACL solutions for Laravel store the permissions rules in the database or other persistance layer. This is great if access is dynamic but for applications with set permissions by roles this makes modification more difficult. Adding new resources, permissions, or roles requires runnning db queries via a migration or other means. With this package the permissions are stored in code and thus in version control (hopefully).

Rather than reinvent the wheel this package makes use of the Acl package from Zend Framework. Documentation for the Laminas\\Permissions\\Acl can be found at

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

[](#installation)

Run `composer require spekkionu/laravel-zend-acl` from your project root.

Setup
-----

[](#setup)

### Laravel

[](#laravel)

1. For Laravel versions less than 5.5 Add `'Spekkionu\ZendAcl\ZendAclServiceProvider',` to the service provider list in `config/app.php`. This step is not necessary for Laravel 5.5+.
2. Add `'Acl' => 'Spekkionu\ZendAcl\Facades\Acl',` to the list of aliases in `config/app.php`.
3. Run `php artisan vendor:publish --provider="Spekkionu\ZendAcl\ZendAclServiceProvider"`

After publishing the permissions will be defined in `routes/acl.php`.

### Lumen

[](#lumen)

1. Add `$app->register(Spekkionu\ZendAcl\ZendAclLumenServiceProvider::class);` to the `Register Service Providers` section in `bootstrap/app.php`.
2. Copy the `vendor/spekkionu/laravel-zend-acl/src/config/zendacl.php` file to the `config` folder in the app root (create the folder if it does not exist).
3. Copy the `vendor/spekkionu/laravel-zend-acl/src/config/acl.php` file to the `routes` folder (this folder should also contain the `web.php` routes file).

Migrating from version 6
------------------------

[](#migrating-from-version-6)

The namespace for the Zend framework libraries has changed from Zend to Laminas.

To migrate to the 7.x branch you will need to change any references to the old Zend namespace in your project to the new Laminas namespace.

This will likely include changing the RoleInterface your user model implements from `Zend\Permissions\Acl\Role\RoleInterface` to `Laminas\Permissions\Acl\Role\RoleInterface`.

Also anywhere you are type hinting for `Zend\Permissions\Acl\Acl` to `Laminas\Permissions\Acl\Acl`.

Usage
-----

[](#usage)

The Laminas\\Permissions\\Acl is available through the Facade Acl or through the acl service in the IOC container. The IOC container can also inject the acl instance by type-hinting Laminas\\Permissions\\Acl\\Acl.

The permissions can be modified at `app/Http/acl.php`.

### Adding a Resource

[](#adding-a-resource)

You can add a new resource using the addResource method.

```
