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

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

fmlimao/php-acl
===============

Simples ACL em PHP para todos os projetos.

1.2.2(6y ago)08MITPHPPHP &gt;7.2CI failing

Since Apr 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/fmlimao/php-acl)[ Packagist](https://packagist.org/packages/fmlimao/php-acl)[ RSS](/packages/fmlimao-php-acl/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (10)Used By (0)

ACL PHP - Simples ACL em PHP para todos os projetos.
====================================================

[](#acl-php---simples-acl-em-php-para-todos-os-projetos)

E quando eu digo simples, é simples mesmo!

Instalação
----------

[](#instalação)

```
composer require fmlimao/php-acl

```

Como usar
---------

[](#como-usar)

```
$acl = new Fmlimao\Acl;

```

Basicamente, basta você associar um Papel a um Recurso e a um Privilégio no momento de dar a permissão ou de remover a permissão:

```
$acl->allow('Papel', 'Recurso', 'Privilégio');

// ou

$acl->deny('Papel', 'Recurso', 'Privilégio');

```

Também é possivel enviar um array em qualquer um dos três parâmetros:

```
$acl->allow(['Papel 1', 'Papel 2'], ['Recurso 1', Recurso 2', Recurso 3'], ['Privilégio 1']);

```

Podemos passar `null` como valor em qualquer um dos parâmetros.

- Se o Papel for `null`, então os Recursos e seus Provilégios serão atribuidos a todos os Papeis.
- Se o Recurso for `null`, então os Privilégios serão dados a todos os Recursos.
- Se o Privilégio for `null`, então os Papeis terão todos os Privilégios deste Recurso.

Exemplo:

```
// Todos os Papeis terão esses Privilégios nestes Recursos.
$acl->allow(null, ['products', 'categories'], ['list', 'update']);

// O papel "admin" terá esses Privilégios em todos os Recursos
$acl->allow('admin', null, ['create', 'delete']);

// O papel "member" terá todos os Privilégios no recurso "orders"
$acl->allow('member', 'orders', null);

```

E para verificar se tem ou não a permissão, basta chamar assim:

```
$isAllowed = $acl->isAllowed('Papel', 'Recurso', 'Privilégio');

```

Aqui também é permitido passar arrays como parâmetros:

```
$isAllowed = $acl->isAllowed(['Papel 1', 'Papel 2'], ['Recurso 1', Recurso 2', Recurso 3'], ['Privilégio 1']);

```

Também é possível passar um array nos argumentos:

```
$isAllowed = $acl->isAllowed(['Papel 1', 'Papel 2'], ['Recurso 1', Recurso 2', Recurso 3'], ['Privilégio 1']);

```

Herança de Papeis
-----------------

[](#herança-de-papeis)

Os Papeis poderão estar vinculadas umas as outras, gerando uma herança entre elas.

```
$acl = new Fmlimao\Acl;

$acl->addRole('Papel 1');

// Papel 2 é filho do Papel 1.
$acl->addRole('Papel 2', 'Papel 1');

// Papel 3 é filho do Papel 2.
$acl->addRole('Papel 3', 'Papel 2');

// Papel 4 é filho do Papel 3.
$acl->addRole('Papel 4', 'Papel 3');

$acl->allow('Papel 1', 'Recurso 1', 'Listar');
$acl->allow('Papel 2', 'Recurso 1', 'Criar');
$acl->allow('Papel 3', 'Recurso 1', 'Exibir');
$acl->allow('Papel 4', 'Recurso 1', ['Alterar', 'Deletar']);
$acl->deny('Papel 4', 'Recurso 1', 'Listar');

$alloweds = [];

// Retorna TRUE por causa do Papel 2.
$alloweds[] = $acl->isAllowed('Papel 4', 'Recurso 1', 'Criar');

// Retorna TRUE por causa do Papel 3.
$alloweds[] = $acl->isAllowed('Papel 4', 'Recurso 1', 'Exibir');

// Retorna TRUE por causa do próprio Papel 4.
$alloweds[] = $acl->isAllowed('Papel 4', 'Recurso 1', 'Alterar');

// Retorna FALSE pois nem o papel atual e nem seus pais tem esse privilégio.
$alloweds[] = $acl->isAllowed('Papel 4', 'Recurso 1', 'Vincular');

// Retorna FALSE. Apesar do Papel 1 ter esse privilégio, foi retirado do Papel 4
$alloweds[] = $acl->isAllowed('Papel 4', 'Recurso 1', 'Listar');

var_dump($alloweds);

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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 ~3 days

Total

5

Last Release

2212d ago

PHP version history (2 changes)1.0.0PHP &gt;5.4

1.2.0PHP &gt;7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ecd3df0d7e09c5728e4d5c992d6332f5e931e267cc2ce97532dbe186a45bb2c?d=identicon)[fmlimao](/maintainers/fmlimao)

---

Top Contributors

[![fmlimao](https://avatars.githubusercontent.com/u/5287567?v=4)](https://github.com/fmlimao "fmlimao (22 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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