PHPackages                             mohit-singh/zf2auth-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. mohit-singh/zf2auth-acl

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

mohit-singh/zf2auth-acl
=======================

This is ACL module plug with zfcuser module this is heighly configurable abd provide different services at controller, view and module level.

V2.0.0(11y ago)56021PHPPHP &gt;=5.3

Since May 22Pushed 11y ago2 watchersCompare

[ Source](https://github.com/Mohit-Singh/ZF2AuthAcl)[ Packagist](https://packagist.org/packages/mohit-singh/zf2auth-acl)[ Docs](https://github.com/Mohit-Singh/ZF2AuthAcl)[ RSS](/packages/mohit-singh-zf2auth-acl/feed)WikiDiscussions zfcuser\_acl Synced yesterday

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

ZF2-Auth-ACL
============

[](#zf2-auth-acl)

Branch: zfcuser\_acl
--------------------

[](#branch-zfcuser_acl)

This this the ZF2 ACL module forked from arvind2110/ZF2-Auth-ACL and Plugged with zfcuser module. it will provide role base access and switching between roles , provides custom permission denied template , plug ins to access role at controller , view and module level. All the role, resource and permission are stored in databases.

How to Use it
-------------

[](#how-to-use-it)

using composer add

```
  "require" : {
       ...
    "mohit-singh/zf2auth-acl": "V1.0.1"
  }

```

Enable the module in application.config.php

```
 'modules' => array(
	...
        'ZF2AuthAcl'
    ),
```

then copy and rename the following,

```
copy vendor/mohit-singh/zf2auth-acl/config/aclAuth.local.php.dist to config/autoload/aclAuth.local.php

```

Add the depended table from

```
vendor/mohit-singh/zf2auth-acl/data/data.sql

```

ADD role for user in table e.g.

```
INSERT INTO `role` (`role_name`, `status`) VALUES ('Role1', 'Active');
INSERT INTO `role` (`role_name`, `status`) VALUES ('Role2', 'Active');
INSERT INTO `role` (`role_name`, `status`) VALUES ('Role3', 'Active');

```

ADD resources, resources are your controller name through which you invoke your controller, for me it's "Application\\Controller\\Index" e.g.

```
INSERT INTO `resource` (`resource_name`) VALUES ('Application\\Controller\\Index');

```

ADD Permissions , permission are the action, you have to associated all action with there controller resource e.g.

```
INSERT INTO `permission` (`permission_name`, `resource_id`) VALUES ('index', 1);
INSERT INTO `permission` (`permission_name`, `resource_id`) VALUES ('show', 1);

```

ADD role permission , you have to decided which role have which permission e.g.

```
INSERT INTO `role_permission` (`role_id`, `permission_id`) VALUES (1, 1);
INSERT INTO `role_permission` (`role_id`, `permission_id`) VALUES (1, 2);

```

ADD user role , you have to decide which user have which role , this can be done manually or using some custom script.

```
INSERT INTO `user_role` (`user_id`, `role_id`) VALUES (1, 1);
INSERT INTO `user_role` (`user_id`, `role_id`) VALUES (2, 2);

```

NOTE:- please check the aclAuth.local.php con-fig for the default role, it Should be one of the role whatever you insert in the database.

after all these configuration is done you are ready to use ACL module

Services
--------

[](#services)

Remove ACL from a URL and make it global, access to all , add link here

```
// in config/autoload/aclAuth.local.php
'globalList' => array(
		      'Application\Controller\Index-index'
	   ),
```

Remove ACL from a URL and make it global before login , add link here

```
// in config/autoload/aclAuth.local.php
'beforeLoginList' => array(
		      'Application\Controller\Index-index'
	   ),
```

Custom template for permission denied, add new template path here

```
// in config/autoload/aclAuth.local.php
'ACL_Template' =>'zf2-auth-acl/index/permission.phtml'
```

Role base services at controller

```
// Check user has role or not , return true, false
$this->userAuthRole()->userHasRole();

//Get  user current role
$this->userAuthRole()->getRoleName();

//get All valid role for the current user
$this->userAuthRole()->getUserValidRole();

//Switch between roles
$this->userAuthRole()->switchRole('ADMIN');
```

at view level

```
// Check user has role or not , return true, false
$this->roleAuth()->userHasRole();

//Get  user current role
$this->roleAuth()->getRoleName();

//get All valid role for the current user
$this->roleAuth()->getUserValidRole();

//Switch between roles
$this->roleAuth()->switchRole('ADMIN');
```

at module level

```
$roleAtuth = $serviceManager->get('roleAuthService');

// Check user has role or not , return true, false
$roleAtuth->userHasRole();

//Get  user current role
$roleAtuth->getRoleName();

//get All valid role for the current user
$roleAtuth->getUserValidRole();

//Switch between roles
$roleAtuth->switchRole('ADMIN');
```

It Also provide cache mechanism to store role, resource and permission in cache. you can configure the caching here

```
    /**
     * This cache is used the disk file system to store date with the following options.
     */
    'fileCache' => array(
        'cache_dir' => './data/cache',
        'namespace' => 'systemCache',
        'dir_level' => 2,
        'filePermission' => 0666,
        'dirPermission' => 0755
    ),
```

you can also access file system cache in your project like this

```
// store item in filesystem cache
        $this->getServiceLocator()->get('Zend\Cache\Storage\Filesystem')->setItem('foo', 'taxi');

// get item from filesystem cache
        echo 'Cached Item is:- '.$this->getServiceLocator()->get('Zend\Cache\Storage\Filesystem')->getItem('foo');
```

you are using file system cache so you have to give permission to the cache folder

```
> sudo chmod -R 0777 data/cache

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~1 days

Total

3

Last Release

4331d ago

Major Versions

V1.0.1 → V2.0.02014-07-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3784341?v=4)[Mohit K.Singh](/maintainers/Mohit-Singh)[@Mohit-Singh](https://github.com/Mohit-Singh)

---

Top Contributors

[![Mohit-Singh](https://avatars.githubusercontent.com/u/3784341?v=4)](https://github.com/Mohit-Singh "Mohit-Singh (20 commits)")[![arvind2110](https://avatars.githubusercontent.com/u/7286603?v=4)](https://github.com/arvind2110 "arvind2110 (10 commits)")

---

Tags

authaclzf2zfcuserZF-CommonsZF2 AuthZF2 ACLZF2 Auth Acl

### Embed Badge

![Health badge](/badges/mohit-singh-zf2auth-acl/health.svg)

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

###  Alternatives

[zizaco/entrust

This package provides a flexible way to add Role-based Permissions to Laravel. Supports laravel 5|6|7|8

6.0k5.3M60](/packages/zizaco-entrust)[codegreencreative/laravel-samlidp

Make your PHP Laravel application an Identification Provider using SAML 2.0. This package allows you to implement your own Identification Provider (idP) using the SAML 2.0 standard to be used with supporting SAML 2.0 Service Providers (SP).

263763.5k1](/packages/codegreencreative-laravel-samlidp)[goalio/goalio-forgotpassword

Adding Forgot Password functionalitiy to ZfcUser

4362.2k1](/packages/goalio-goalio-forgotpassword)[gghughunishvili/entrust

This package provides a flexible way to add Role-based Permissions to Laravel/Lumen 6

27524.0k](/packages/gghughunishvili-entrust)[goalio/goalio-rememberme

Adding Remember Me functionalitiy to ZfcUser

3243.5k3](/packages/goalio-goalio-rememberme)[acoustep/entrust-gui

A GUI for the Entrust package.

11425.7k](/packages/acoustep-entrust-gui)

PHPackages © 2026

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