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

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

rarog/user-rbac
===============

A Zend Framework module to easily integrate ZfcUser and ZfcRbac

v2.0.0(8y ago)03751MITPHPPHP ^5.6 || ^7.0

Since Feb 4Pushed 8y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (4)Versions (11)Used By (1)

UserRbac
========

[](#userrbac)

[![Master Branch Build Status](https://camo.githubusercontent.com/7599e4c300a4d0ff074b03a84ba69796e570a8fee617ad83bd787f6d7649e4e5/68747470733a2f2f6170692e7472617669732d63692e6f72672f7261726f672f55736572526261632e7376673f6272616e63683d6d6173746572)](http://travis-ci.org/rarog/UserRbac)[![Coverage Status](https://camo.githubusercontent.com/357981892d31ba8bb6f98ff92c0ed1783a60d8c8b1436e4de89791a410793105/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7261726f672f55736572526261632f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/rarog/UserRbac?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/c35a52b67ad54e0e09baf2df577779b24f118993c206bde84af77db6915bc45d/68747470733a2f2f706f7365722e707567782e6f72672f7261726f672f757365722d726261632f762f737461626c652e706e67)](https://packagist.org/packages/rarog/user-rbac)[![Latest Unstable Version](https://camo.githubusercontent.com/1d0089aec09817cb0e3153b590ee4f4a83c7e0dd63b5894d9c1c74537ab759e2/68747470733a2f2f706f7365722e707567782e6f72672f7261726f672f757365722d726261632f762f756e737461626c652e706e67)](https://packagist.org/packages/rarog/user-rbac)[![Total Downloads](https://camo.githubusercontent.com/7162e1ac1b63592f275cbf8434d4e5d60b1c38953ad26d275f547821db08f0ee/68747470733a2f2f706f7365722e707567782e6f72672f7261726f672f757365722d726261632f646f776e6c6f6164732e706e67)](https://packagist.org/packages/rarog/user-rbac)

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

Introduction
------------

[](#introduction)

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.

Versions
--------

[](#versions)

Please use below table to figure out what version of ZfcUser you should use.

UserRbac versionSupported Zend Framework version0.x&lt;= 2.51.x&gt;= 2.6 &lt; 32.x&gt;= 3.xFeatures
--------

[](#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 `"rarog/user-rbac": "^2.0",` to your composer.json and run `php composer.phar update`
- Import the schema for corresponding database in `data` folder
- Enable this module in `config/application.config.php`
- Copy file located in `vendor/rarog/user-rbac/config/user-rbac.global.php.dist` 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/rarog/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/rarog/user-rbac/config/user-rbac.global.php.dist`.

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)
{
    $app = $e->getApplication();
    $sm = $app->getServiceManager();
    $em = $app->getEventManager();

    $listener = $sm->get(\UserRbac\View\Strategy\SmartRedirectStrategy::class);
    $listener->attach($em);
}
```

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

[](#known-limitation)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 60.2% 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 ~170 days

Recently: every ~82 days

Total

10

Last Release

2947d ago

Major Versions

0.1.1 → v1.02017-04-27

v1.0.3 → v2.0.02018-04-19

PHP version history (2 changes)0.0.1-beta1PHP &gt;=5.4

v1.0PHP ^5.6 || ^7.0

### Community

Maintainers

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

---

Top Contributors

[![rarog](https://avatars.githubusercontent.com/u/2520875?v=4)](https://github.com/rarog "rarog (77 commits)")[![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

ZendFrameworkmodulezf3

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[filsh/yii2-oauth2-server

OAuth2 Server for PHP

331523.9k12](/packages/filsh-yii2-oauth2-server)[zfr/rbac

Zend Framework 3 prototype for Zend\\Permissions\\Rbac.

271.1M7](/packages/zfr-rbac)[hrevert/ht-img-module

Image manipulation module for Zend Framework 2

1829.6k2](/packages/hrevert-ht-img-module)[lm-commons/lmc-rbac-mvc

Laminas Framework MVC Module that provides a layer of features of Laminas\\Permissions\\Rbac

12401.0k7](/packages/lm-commons-lmc-rbac-mvc)[silverstripe/mfa

Enable multi-factor authentication with fallback codes

10346.1k8](/packages/silverstripe-mfa)[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)
