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

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

ajtarragona/acl
===============

ACL Package for access control

v2.0.6(8mo ago)01.7kMITPHPPHP &gt;=7.0.0

Since Apr 30Pushed 8mo agoCompare

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

READMEChangelogDependencies (6)Versions (21)Used By (0)

Tarragona ACL for Laravel
=========================

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

Aquest paquet incorpora una capa de Control d'Accés (Acces Control List) que permet definir, usuaris, rols, permisos i grups. Utilitza internament el paquet [Laratrust](https://laratrust.santigarcor.me/).

També s'inropora un backend d'administració d'aquesta capa ACL. Aquest backend depèn del paquet [ajtarragona/web-components](https://github.com/ajtarragona/web-components) per funcionar correctament.

[![Latest Stable Version](https://camo.githubusercontent.com/871d5409b17a4af1e7f78ff6802c4de7e366cda5b9481aa816188685aa86a20a/687474703a2f2f706f7365722e707567782e6f72672f616a7461727261676f6e612f61636c2f76)](https://packagist.org/packages/ajtarragona/acl) [![Total Downloads](https://camo.githubusercontent.com/ea24e76e3888a4457912191850090a96bffe6d4a1d6e5205aaa9175d86b5ddf5/687474703a2f2f706f7365722e707567782e6f72672f616a7461727261676f6e612f61636c2f646f776e6c6f616473)](https://packagist.org/packages/ajtarragona/acl) [![Latest Unstable Version](https://camo.githubusercontent.com/aa3c0997165132283786f479810b4d8155a9f2a9a9a43833f1bff278279a7e98/687474703a2f2f706f7365722e707567782e6f72672f616a7461727261676f6e612f61636c2f762f756e737461626c65)](https://packagist.org/packages/ajtarragona/acl) [![License](https://camo.githubusercontent.com/0a3f5a17d5b137163fb14854cc5119bf566f8b77b866cf6cddf2aeba12c408ee/687474703a2f2f706f7365722e707567782e6f72672f616a7461727261676f6e612f61636c2f6c6963656e7365)](https://packagist.org/packages/ajtarragona/acl) [![PHP Version Require](https://camo.githubusercontent.com/d1529cb50ac2e9906f5dc09421f202d617265b74e9d62577697b1c1a7b958d30/687474703a2f2f706f7365722e707567782e6f72672f616a7461727261676f6e612f61636c2f726571756972652f706870)](https://packagist.org/packages/ajtarragona/acl)

Instal·lació
------------

[](#installació)

```
composer require ajtarragona/acl
```

Si volem fer servir el backend a més hem de requerir el paquet web-components.

```
composer require ajtarragona/web-components
```

Configuració Inicial
--------------------

[](#configuració-inicial)

A l'arxiu `config/auth.php` definim la classe del package al user provider:

```
    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => Ajtarragona\ACL\Models\User::class,
        ],
    ]
```

Si fem servir LDAP, també canviar el model a l'arxiu `config/ldap_auth.php`

```
'model' => Ajtarragona\ACL\Models\User::class,
```

Si no trobem l'arxiu, cal publicar-lo amb la comanda:

```
php artisan vendor:publish --provider=Adldap\Laravel\AdldapAuthServiceProvider
```

Publiquem la configuració de Laratrust.

```
php artisan vendor:publish --tag="laratrust"
```

A l'arxiu `config/laratrust.php` (si volem fer servir grups):

1. posem l'atribut `teams.enabled` a `true`:

```
 ...
 'teams' => [
    'enabled' => true,
 ]
 ...
```

2. Definim els models:

```
'user_models' => [
	'users' => 'Ajtarragona\ACL\Models\User',
],
...
'models' => [
   /**
    * Role model
    */
   'role' => 'Ajtarragona\ACL\Models\Role',

   /**
    * Permission model
    */
   'permission' => 'Ajtarragona\ACL\Models\Permission',

   /**
    * Team model
    */
   'team' => 'Ajtarragona\ACL\Models\Team',

],
```

3. Finalment, executem la següent comanda:

```
php artisan ajtarragona:acl-setup
```

Això prepararà les taules de la base de dades, si no existeixen, executarà la migració i crearà els permisos, rols i usuaris per defecte.

> Es poden modificar els rols, permisos i usuaris per defecte a l'arxiu `config/acl_seed.php`, publicant prèviament la configuració del paquet:

```
php artisan vendor:publish --tag=ajtarragona-acl
```

Se'ns crearà un usuari `acl` amb password `acl` amb els rols i permissos necessaris.

Backend
-------

[](#backend)

Podem accedir al backend d'administració a través de la ruta `ajtarragona/acl`. Caldrà que introduim un usuari vàlid que tingui el permís de gestió d'autoritzacions.

Es pot deshabilitar el backend configurant la variable `ACL_BACKEND` a l'arxiu `.env`.

Ús
--

[](#ús)

Mirar la documentació de [Laratrust](https://laratrust.santigarcor.me/) per a més informació.

A grans trets per comprovar si un usuari té un determinat rol o permís, ho podem fer a través d'un middleware a les rutes:

```
Route::group(['middleware' => ['role:admin']], function() {
    ...
});
```

```
Route::group(['middleware' => ['permission:edit-post']], function() {
    ...
});
```

O bé amb directives blade a les vistes:

```
@role('admin')
    This is visible to users with the admin role. Gets translated to
    \Laratrust::hasRole('admin')
@endrole
```

```
@permission('manage-admins')
    This is visible to users with the given permissions. Gets translated to
    \Laratrust::can('manage-admins'). The @can directive is already taken by core
    laravel authorization package, hence the @permission directive instead.
@endpermission
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance62

Regular maintenance activity

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~119 days

Recently: every ~430 days

Total

20

Last Release

243d ago

Major Versions

v0.0.1 → v1.0.12019-04-30

v1.0.12 → v2.0.02020-10-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/eae0bc56bebf7416d9c7ad9f0c8a7aa91e8911c8f8a8a34207d90a201df3deff?d=identicon)[ajtarragona](/maintainers/ajtarragona)

---

Top Contributors

[![ajtarragona](https://avatars.githubusercontent.com/u/45968689?v=4)](https://github.com/ajtarragona "ajtarragona (40 commits)")

---

Tags

laravelaccesslistacllaravel5control

### Embed Badge

![Health badge](/badges/ajtarragona-acl/health.svg)

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

###  Alternatives

[jeremykenedy/laravel-roles

A Powerful package for handling roles and permissions in Laravel. Supports Laravel 5.3 up to 12.

1.0k817.6k6](/packages/jeremykenedy-laravel-roles)[imanghafoori/laravel-heyman

A package to help you write expressive defensive code in a functional manner

92637.0k3](/packages/imanghafoori-laravel-heyman)[spekkionu/laravel-zend-acl

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

4181.3k](/packages/spekkionu-laravel-zend-acl)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12

6641.4k1](/packages/hasinhayder-tyro)

PHPackages © 2026

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