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

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

luoyt/rbac
==========

rbac

v1.1(8y ago)133MITPHPPHP &gt;=5.4.4

Since Nov 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/luoyt/rbac)[ Packagist](https://packagist.org/packages/luoyt/rbac)[ RSS](/packages/luoyt-rbac/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

rbac
====

[](#rbac)

基于角色的数据库方式验证类

只支持thinkphp5版本

RBAC 权限验证配置
-----------

[](#rbac-权限验证配置)

```
return [
    // RBAC 权限验证
    'user_auth_on'            => true, // 是否开启认证
    'user_auth_type'          => 2, // 默认认证类型 1 - 登录认证 | 2 - 实时认证
    'user_auth_key'           => 'auth_id',    // 用户认证 SESSION 标记
    'admin_auth_key'          => 'administrator',
    'user_auth_model'         => '',    // 默认验证数据表模型
    'user_auth_gateway'       => '/login',    // 默认认证网关
    'not_auth_controller'     => 'Index',        // 默认无需认证控制器，多级控制器使用点语法，严格大小写，多个逗号隔开
    'require_auth_controller' => '',        // 默认需要认证控制器，多级控制器使用点语法，严格大小写，多个逗号隔开
    'not_auth_action'         => '',        // 默认无需认证方法，全部小写，多个逗号隔开
    'require_auth_action'     => '',        // 默认需要认证方法，全部小写，多个逗号隔开
    'common_auth_name'        => 'common',        // 公共授权控制器名称和方法名称
    'guest_auth_on'           => false,    // 是否开启游客授权访问
    'guest_auth_id'           => 0,     // 游客的用户ID

    'role_table'   => 'admin_role', // 角色表名称，不包含表前缀
    'user_table'   => 'admin_role_user', // 用户角色关系表名称，不包含表前缀
    'access_table' => 'admin_access', // 权限表名称，不包含表前缀
    'node_table'   => 'admin_node', // 节点表名称，不包含表前缀
];
```

相关表
---

[](#相关表)

```
CREATE TABLE IF NOT EXISTS `think_access` (
  `role_id` smallint(6) unsigned NOT NULL,
  `node_id` smallint(6) unsigned NOT NULL,
  `level` tinyint(1) NOT NULL,
  `module` varchar(50) DEFAULT NULL,
  KEY `groupId` (`role_id`),
  KEY `nodeId` (`node_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `think_node` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  `title` varchar(50) DEFAULT NULL,
  `status` tinyint(1) DEFAULT '0',
  `remark` varchar(255) DEFAULT NULL,
  `sort` smallint(6) unsigned DEFAULT NULL,
  `pid` smallint(6) unsigned NOT NULL,
  `level` tinyint(1) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `level` (`level`),
  KEY `pid` (`pid`),
  KEY `status` (`status`),
  KEY `name` (`name`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `think_role` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  `pid` smallint(6) DEFAULT NULL,
  `status` tinyint(1) unsigned DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pid` (`pid`),
  KEY `status` (`status`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `think_role_user` (
  `role_id` mediumint(9) unsigned DEFAULT NULL,
  `user_id` char(32) DEFAULT NULL,
  KEY `group_id` (`role_id`),
  KEY `user_id` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

Total

2

Last Release

3087d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c43c90bd8e59c2b3ab1d7b240ca0d9ea24f585d27bbfaa77c1788168a0fc91f?d=identicon)[luoyt](/maintainers/luoyt)

---

Top Contributors

[![luoyt](https://avatars.githubusercontent.com/u/1060939?v=4)](https://github.com/luoyt "luoyt (5 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M100](/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.2M117](/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)
