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

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

mikemclin/php-acl
=================

Role-based permissions for PHP

0.1.4(10y ago)13.1k1MITPHPPHP &gt;=5.4.0

Since Jul 11Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (6)Used By (0)

PHP ACL
=======

[](#php-acl)

---

About
-----

[](#about)

PHP ACL *(Access Control List)* is a service that allows you to protect/enable functionality based on the current user's assigned role(s), and those role(s) permissions (abilities). So, if the current user has a "moderator" role, and a moderator can "ban\_users", then the current user can "ban\_users".

---

Documentation
-------------

[](#documentation)

### `MikeMcLin\Acl|Acl` methods

[](#mikemclinaclacl-methods)

#### `resume()`

[](#resume)

Restore data from storage.

###### Returns

[](#returns)

**boolean** - true if web storage existed, false if it didn't

#### `attachRole(role)`

[](#attachrolerole)

Attach a role to the current user. A user can have multiple roles.

###### Parameters

[](#parameters)

ParamTypeExampleDetails`role`string`"admin"`The role label#### `detachRole(role)`

[](#detachrolerole)

Remove a role from the current user

###### Parameters

[](#parameters-1)

ParamTypeExampleDetails`role`string`"admin"`The role label#### `flushRoles()`

[](#flushroles)

Remove all roles from current user

#### `hasRole(role)`

[](#hasrolerole)

Check if the current user has role attached

###### Returns

[](#returns-1)

**boolean**

#### `setAbilities(abilities)`

[](#setabilitiesabilities)

Set the abilities object (overwriting previous abilities).

###### Parameters

[](#parameters-2)

ParamTypeDetails`abilities`objectEach property on the abilities object should be a role. Each role should have a value of an array. The array should contain a list of all of the role's abilities.###### Example

[](#example)

```
var abilities = (object)[
  guest: ['login'],
  user: ['logout', 'view_content'],
  admin: ['logout', 'view_content', 'manage_content']
]
setAbilities(abilities);
```

#### `addAbility(role, ability)`

[](#addabilityrole-ability)

Add an ability to a role

###### Parameters

[](#parameters-3)

ParamTypeExampleDetails`role`string`"admin"`The role label`ability`string`"create_users"`The ability/permission label#### `can(ability)`

[](#canability)

Does current user have permission to do the given ability?

###### Returns

[](#returns-2)

**boolean**

###### Example

[](#example-1)

```
// Setup some abilities
$acl->addAbility('moderator', 'ban_users');
$acl->addAbility('admin', 'create_users');

// Add moderator role to the current user
$acl->attachRole('moderator');

// Check if the current user has these permissions
$acl->can('ban_users'); // returns true
$acl->can('create_users'); // returns false
```

---

License
-------

[](#license)

The MIT License

Angular ACL Copyright (c) 2015 Mike McLin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

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

Total

5

Last Release

3785d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51d520461cb8178303489e606806b6057e107083bf2fc30b2071583b574c2563?d=identicon)[mikemclin](/maintainers/mikemclin)

---

Top Contributors

[![mikemclin](https://avatars.githubusercontent.com/u/1570155?v=4)](https://github.com/mikemclin "mikemclin (7 commits)")

### Embed Badge

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

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

###  Alternatives

[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)[illuminate/auth

The Illuminate Auth package.

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

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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