PHPackages                             zunnu/enforcer - 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. zunnu/enforcer

ActiveCakephp-plugin[Authentication &amp; Authorization](/categories/authentication)

zunnu/enforcer
==============

Enforcer is a simple lightweight acl plugin for CakePHP

1.3(4y ago)37MITPHP

Since Aug 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/zunnu/enforcer)[ Packagist](https://packagist.org/packages/zunnu/enforcer)[ RSS](/packages/zunnu-enforcer/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (4)Dependencies (1)Versions (7)Used By (0)

Enforcer
========

[](#enforcer)

Enforcer is a simple lightweight acl plugin for CakePHP 3.x

Requirements
------------

[](#requirements)

- CakePHP 3.x
- PHP 7.2 &gt;

Installing Using [Composer](http://getcomposer.org)
---------------------------------------------------

[](#installing-using-composer)

`cd` to the root of your app folder (where the `composer.json` file is) and run the following command:

```
composer require zunnu/enforcer

```

Then load the plugin by using CakePHP's console:

```
./bin/cake plugin load Enforcer

```

Next create the tables:

```
./bin/cake migrations migrate -p Enforcer

```

Usage
-----

[](#usage)

You will need to modify your `src/Controller/AppController.php` and load the Enforcer component in the `initialize()` function

```
$this->loadComponent('Enforcer.Enforcer', [
    'unauthorizedRedirect' => [
        'plugin' => false,
        'controller' => 'Users',
        'action' => 'login',
        'prefix' => false
    ],
    'protectionMode' => 'everything' // everything | filters
]);
```

The `unauthorizedRedirect` will tell Enforcer where to redirect if the user has permission error. The `protectionMode` will tell Enforcer how to handle permissions.

protectionModesREADMEeverythingEnforcer will automaticly try to protect all public controller functionfiltersEnforcer will protect the controllers where the protection is called from the `beforeFilter()`If the `protectionMode` **filters** is enabled you need to add the

```
public function beforeFilter(Event $event) {
    parent::beforeFilter($event);

    // permission load
    return $this->Enforcer->hasAccess($this->request, $this->Auth->user());
}
```

Permissions
-----------

[](#permissions)

The migrations will create tree different groups. You can add, modify or delete groups by going to

GroupsREADMEadminAll powerfulluserDefault user groupguestSite visitorsThe default admin group should be able to access the permissions page. You should be able to access the page using this url [![Enforcer permissions](https://camo.githubusercontent.com/7538627652f10ef3ccc4ee5ce6e686075249f0545c7bde6ed944e9fc5c93a7a4/68747470733a2f2f696d6775722e636f6d2f4e323867626c4b2e706e67)](https://camo.githubusercontent.com/7538627652f10ef3ccc4ee5ce6e686075249f0545c7bde6ed944e9fc5c93a7a4/68747470733a2f2f696d6775722e636f6d2f4e323867626c4b2e706e67)
[![Enforcer permissions](https://camo.githubusercontent.com/4cbb2f108d7edcce22282087406206b59619a218455e9a45a0e5f4bda04abf6c/68747470733a2f2f692e696d6775722e636f6d2f566b577a6c674a2e706e67)](https://camo.githubusercontent.com/4cbb2f108d7edcce22282087406206b59619a218455e9a45a0e5f4bda04abf6c/68747470733a2f2f692e696d6775722e636f6d2f566b577a6c674a2e706e67)

If the request is ajax the permission error will look like this: [![Enforcer permissions](https://camo.githubusercontent.com/788ff335b95b3ad7bff0a0927ccacb97a229df446629704e5a94a0945be67b78/68747470733a2f2f692e696d6775722e636f6d2f675444316c4a432e706e67)](https://camo.githubusercontent.com/788ff335b95b3ad7bff0a0927ccacb97a229df446629704e5a94a0945be67b78/68747470733a2f2f692e696d6775722e636f6d2f675444316c4a432e706e67)

Todos
-----

[](#todos)

- User specific permissions
- Groupped controllers. Like the user only has access to billing

License
-------

[](#license)

Licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

4

Last Release

1665d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/87be5ff062749fe4a745840ccf9921ca94a513983363abd7b925248f0c632769?d=identicon)[zunnu](/maintainers/zunnu)

---

Top Contributors

[![zunnu](https://avatars.githubusercontent.com/u/7551907?v=4)](https://github.com/zunnu "zunnu (27 commits)")

---

Tags

aclcakephpcakephp-pluginlightweightphpcakephpacllightweight

### Embed Badge

![Health badge](/badges/zunnu-enforcer/health.svg)

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

###  Alternatives

[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

129228.6k10](/packages/dereuromark-cakephp-tinyauth)[markstory/acl_extras

Additional tools for managing DB ACL in CakePHP applications.

155311.0k](/packages/markstory-acl-extras)[cakedc/users

Users Plugin for CakePHP

524897.0k16](/packages/cakedc-users)[admad/cakephp-jwt-auth

CakePHP plugin for authenticating using JSON Web Tokens

160680.3k8](/packages/admad-cakephp-jwt-auth)[ivanamat/cakephp3-aclmanager

AclManager plugin for CakePHP 3.x

2715.2k](/packages/ivanamat-cakephp3-aclmanager)[cakedc/auth

Auth objects for CakePHP

31630.0k2](/packages/cakedc-auth)

PHPackages © 2026

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