PHPackages                             codemix/hybridauthmanager - 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. codemix/hybridauthmanager

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

codemix/hybridauthmanager
=========================

An AuthManager for Yii that stores the hierarchy in a flat PHP file and the assignmens in DB

04322PHP

Since Aug 22Pushed 12y ago2 watchersCompare

[ Source](https://github.com/codemix/hybridauthmanager)[ Packagist](https://packagist.org/packages/codemix/hybridauthmanager)[ RSS](/packages/codemix-hybridauthmanager/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

HybridAuthManager
=================

[](#hybridauthmanager)

An AuthManager for Yii that stores the hierarchy in a flat PHP file and the assignmens in DB.

This class is a combination of CDbAuthManager and CPhpAuthManager:

- The authorization hierarchy is stored in a flat PHP file
- Authorization assignments are stored in the database

This is useful if the authorization hierarchy is almost static and not very complex.

You can manage the authorization hierarchy in data/auth.php. To not loose the comments there, you should avoid to call any method to create auth items or add child items - even though it's supported.

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

[](#installation)

We recommend to install the extension with [composer](http://getcomposer.org/). Add this to the `require` section of your `composer.json`:

```
'codemix/hybridautmanager' : 'dev-master'

```

> Note: There's no stable version yet.

If you haven't yet, you should also add an alias to composer's vendor directory.

```
$vendor = realpath(__DIR__.'/../vendor');
return array(
    'alias' => array(
        'vendor' => realpath(__DIR__.'/../vendor'), // Fix this path
    ),
    ...
```

Configuration
-------------

[](#configuration)

Add this configuration to your `main.php`:

```
'components' => array(
    'authManager' => array(
        'class' => 'vendor.codemix.hybridautmanager.HybridAuthManager',
    ),
    ...
),
```

Just as with [`CPhpAuthManager`](http://www.yiiframework.com/doc/api/1.1/CPhpAuthManager) you'll need to supply a file with auth rules. By default this is in `data/auth.php`. But here you only have to supply the auth hierarchy:

```
return array(
    // Admin == Root (Full permissions).
    'Admin' => array(
        'type'          => CAuthItem::TYPE_ROLE,
        'description'   => 'Administrator',
        'children'      => array(
            'manageUser',
            'managePosts',
        ),
    ),
    'manageUser' => array(
        'type' => CAuthItem::TYPE_TASK,
        'children' => array(
            'createUser',
            'updateUser',
            'deleteUser',
            'readUser',
        ),
    ),

    'createUser'    => array('type' => CAuthItem::TYPE_OPERATION),
    'updateUser'    => array('type' => CAuthItem::TYPE_OPERATION),
    'deleteUser'    => array('type' => CAuthItem::TYPE_OPERATION),
    'readUser'      => array('type' => CAuthItem::TYPE_OPERATION),

);
```

The content of this file will be cached unless you set `cacheID` to `null`.

The actual Role assignments will be saved in a DB table `auth_assignments` by default. You can change this name with the `assignmentTable` property of the `authManager` component.

Caching
-------

[](#caching)

The component can cache the RBAC hierarchy and auth assignments. You can configure the cache component ID on `cacheID`.

### Caching hierarchy

[](#caching-hierarchy)

By default the hierarchy file content is cache `3600` seconds. You can configure this through `hierarchyCachingDuration`.

### Caching auth assigments

[](#caching-auth-assigments)

You can set the number of seconds to cache auth assignments in `assignmentCachingDuration`. The assignments will be cached per user to avoid DB calls on each request. By default this is set to `0` which means, that assignments will only be cached throughout the current requests, i.e. on consecutive calls of `checkAccess()`.

Set this property to `false` to completely disable caching.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3acf6b979253030380f45271ce4efc9d5f3a207a96fafe6c92da41876ae33b24?d=identicon)[codemix](/maintainers/codemix)

---

Top Contributors

[![mikehaertl](https://avatars.githubusercontent.com/u/675062?v=4)](https://github.com/mikehaertl "mikehaertl (9 commits)")[![phpnode](https://avatars.githubusercontent.com/u/363611?v=4)](https://github.com/phpnode "phpnode (2 commits)")

### Embed Badge

![Health badge](/badges/codemix-hybridauthmanager/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[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)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

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

PHPackages © 2026

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