PHPackages                             niro/rbac-backend - 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. niro/rbac-backend

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

niro/rbac-backend
=================

rbac for backend ,database for mongo

1.94(4y ago)076MITPHP

Since Mar 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Alistair-zhong/rbac)[ Packagist](https://packagist.org/packages/niro/rbac-backend)[ RSS](/packages/niro-rbac-backend/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (2)Versions (19)Used By (0)

RBAC for Backend
----------------

[](#rbac-for-backend)

此工具包开箱即用，集成了接口级别的权限控制模块，自带模型、数据表、中间件，只需要配置数据库账户密码即可使用。

### 安装

[](#安装)

```
COMPOSER_MEMORY_LIMIT=-1 composer require --no-cache niro/rbac-backend

```

### 前提

[](#前提)

- `php` 需要开启 `mongodb` 扩展
- 需要名为 `login` 的路由，例如

```
Route::post('auth/login', [C\Auth\LoginController::class, 'login'])->name('login');
```

### 使用说明

[](#使用说明)

- 检查是否在 `env` 中配置了 `mongodb` 数据库账密
- 检查 `config/database.php` 的 `connection` 是否配置了 `mongodb`，如下案例

```
'connections' => [
    ...
        'mongodb' => [
            'driver' => 'mongodb',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', 27017),
            'database' => env('DB_DATABASE', 'chatbot'),
            'username' => env('DB_USERNAME', ''),
            'password' => env('DB_PASSWORD', ''),
            'options' => [
                // here you can pass more settings to the Mongo Driver Manager
                // see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use

                // 'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'), // required with Mongo 3+
            ],
        ],

    ],
```

- 执行 `php artisan migrate`
- 执行 `php artisan rbac:init`
- 恭喜你，完成了初始化

### 自定义用户模型

[](#自定义用户模型)

1. 可以自行创建用户模型，但必须继承 `Rbac\Models\AdminUser`,并修改 `configs/auth.php` 中的 `providers.admin-users.model` 为您自定义的模型类

### 自定义控制器

[](#自定义控制器)

请将 `src/Controllers/AdminUserController.php` 文件拷贝到你想存放的路径，记得修改其中的命名空间

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Recently: every ~31 days

Total

17

Last Release

1730d ago

Major Versions

0.9 → 1.02021-03-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/a39a12e655b2894c21557ded75a7f9d1de92acbf21bba7e6a1c89fe6fa359d0a?d=identicon)[Alistair-zhong](/maintainers/Alistair-zhong)

---

Top Contributors

[![Alistair-zhong](https://avatars.githubusercontent.com/u/58490734?v=4)](https://github.com/Alistair-zhong "Alistair-zhong (38 commits)")

### Embed Badge

![Health badge](/badges/niro-rbac-backend/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[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)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)

PHPackages © 2026

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