PHPackages                             ujjwal/user-rbac - 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. ujjwal/user-rbac

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

ujjwal/user-rbac
================

A Zend Framework 2 module to easily integrate ZfcUser and ZfcRbac

0.1.1(12y ago)72246[1 issues](https://github.com/ojhaujjwal/UserRbac/issues)MITPHPPHP &gt;=5.4

Since Feb 4Pushed 11y ago3 watchersCompare

[ Source](https://github.com/ojhaujjwal/UserRbac)[ Packagist](https://packagist.org/packages/ujjwal/user-rbac)[ Docs](https://github.com/ojhaujjwal/UserRbac)[ RSS](/packages/ujjwal-user-rbac/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

UserRbac
========

[](#userrbac)

[![Master Branch Build Status](https://camo.githubusercontent.com/caf9c090a9f4fed6937e753324f882bc188d67bc54fa4802a00f7e04bc28ade2/68747470733a2f2f6170692e7472617669732d63692e6f72672f6f6a6861756a6a77616c2f55736572526261632e706e67)](http://travis-ci.org/ojhaujjwal/UserRbac)[![Latest Stable Version](https://camo.githubusercontent.com/a76199064868eceb4eea3c17f3ee7b66ee7d6eaaab9d760915a14393383e2d8b/68747470733a2f2f706f7365722e707567782e6f72672f756a6a77616c2f757365722d726261632f762f737461626c652e706e67)](https://packagist.org/packages/ujjwal/user-rbac)[![Latest Unstable Version](https://camo.githubusercontent.com/7352855625c30394f3b6a306885e1ebffc543f8bf9b6655bbcc9e37282e09b6f/68747470733a2f2f706f7365722e707567782e6f72672f756a6a77616c2f757365722d726261632f762f756e737461626c652e706e67)](https://packagist.org/packages/ujjwal/user-rbac)[![Total Downloads](https://camo.githubusercontent.com/88603bb85b9e9c1b60dc57df2a1985fd9b2bbc388ed00694364c4a6bcf5b80c8/68747470733a2f2f706f7365722e707567782e6f72672f756a6a77616c2f757365722d726261632f646f776e6c6f6164732e706e67)](https://packagist.org/packages/ujjwal/user-rbac)[![Scrutinizer](https://camo.githubusercontent.com/b3a8d2e74f42986cc7a5efa7810fb963c3b0690e36de8a0baea8e7847b92b313/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f6a6861756a6a77616c2f55736572526261632f6261646765732f7175616c6974792d73636f72652e706e673f733d63623032646634653038613564663038633165633734643165343833666264333437646131353466)](https://scrutinizer-ci.com/g/ojhaujjwal/UserRbac/)[![Code Coverage](https://camo.githubusercontent.com/d729185a6e9887c9f6eb21c7b22aa799bb7203c06c2b4feae8ef82d703102950/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f6a6861756a6a77616c2f55736572526261632f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ojhaujjwal/UserRbac/?branch=master)

A Zend Framework 2 module to easily integrate [ZfcUser](https://github.com/ZF-Commons/ZfcUser) and [ZfcRbac](https://github.com/ZF-Commons/zfc-rbac)

Are your tired of doing tedious work of integrating ZfcUser and ZfcRbac again and again? Then, you are in the right place. This module comes to save us. This module, simply, gets roles of a user from the database and passes it to the ZfcRbac. You only need to focus on the domain logic of your application. No more repetive tasks.

Features
--------

[](#features)

1. No need to write code for integrating ZfcUser and ZfcRbac
2. A user`s roles are easily retrievable from the database
3. Addition of `SmartRedirectStrategy`

Installation
------------

[](#installation)

- Add `"ujjwal/user-rbac": "0.1.*",` to your composer.json and run `php composer.phar update`
- Import the schema in `data/mysql.sql`
- Enable this module in `config/application.config.php`
- Copy file located in `vendor/ujjwal/user-rbac/config/user-rbac.global.php` to `./config/autoload/user-rbac.global.php` and change the values as you wish

What it does
------------

[](#what-it-does)

This module registers an identity provider and provides some configuration to ZfcRbac. So, you don't need to create your own identity provider. See [`config/module.config.php`](https://github.com/ojhaujjwal/UserRbac/blob/master/config/module.config.php#L4).

How it works
------------

[](#how-it-works)

It gets a user's roles from the table `user_role_linker` and passes the roles to `ZfcRbac`. This module is best suited when you use `ZfcRbac\Role\InMemoryRoleProvider` as role provider.

Options
-------

[](#options)

Check the options available in `vendor/ujjwal/user-rbac/config/user-rbac.global.php`.

SmartRedirectStrategy
---------------------

[](#smartredirectstrategy)

This module comes with a new strategy called `SmartRedirectStrategy`. This simply redirects to `ZfcUser`'s login page or route, `zfcuser/login` only when the user is unauthenticated. Otherwise, it shows a 403 error page!

#### Usage

[](#usage)

```
public function onBootstrap(EventInterface $e)
{
    $t = $e->getTarget();

    $t->getEventManager()->attach(
        $t->getServiceManager()->get('UserRbac\View\Strategy\SmartRedirectStrategy')
    );
}
```

Known Limitation
----------------

[](#known-limitation)

This module is only ideal for small and meduim web sites as a quick and easy way. For complicated use cases, it may not suit your need.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% 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 ~19 days

Total

4

Last Release

4422d ago

### Community

Maintainers

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

---

Top Contributors

[![ojhaujjwal](https://avatars.githubusercontent.com/u/4995501?v=4)](https://github.com/ojhaujjwal "ojhaujjwal (50 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

---

Tags

ZendFrameworkmodulezf2

### Embed Badge

![Health badge](/badges/ujjwal-user-rbac/health.svg)

```
[![Health](https://phpackages.com/badges/ujjwal-user-rbac/health.svg)](https://phpackages.com/packages/ujjwal-user-rbac)
```

###  Alternatives

[goalio/goalio-rememberme

Adding Remember Me functionalitiy to ZfcUser

3243.5k3](/packages/goalio-goalio-rememberme)[misarji/zend-oauth2

Great OAuth2 client for ZF2. It provides clients for github, google, facebook and linkedin, others are coming soon.

1013.4k](/packages/misarji-zend-oauth2)[org_heigl/hybridauth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

211.9k](/packages/org-heigl-hybridauth)

PHPackages © 2026

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