PHPackages                             wangcb/permission - 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. wangcb/permission

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

wangcb/permission
=================

permission for thinkphp6

1.0.1(6y ago)19MITPHPPHP &gt;=7.1.0

Since Jun 8Pushed 6y agoCompare

[ Source](https://github.com/wangcb/permission)[ Packagist](https://packagist.org/packages/wangcb/permission)[ RSS](/packages/wangcb-permission/feed)WikiDiscussions master Synced 1w ago

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

permission
==========

[](#permission)

/\* Navicat MySQL Data Transfer

Source Server : 192.168.1.186 Source Server Version : 50542 Source Host : 192.168.1.186:3306 Source Database : ruanwen

Target Server Type : MYSQL Target Server Version : 50542 File Encoding : 65001

Date: 2020-06-08 15:53:46 \*/

SET FOREIGN\_KEY\_CHECKS=0;

---

\-- Table structure for model\_has\_permissions

---

DROP TABLE IF EXISTS `model_has_permissions`; CREATE TABLE `model_has_permissions` ( `permission_id` bigint(20) unsigned NOT NULL, `model_type` varchar(190) COLLATE utf8mb4\_unicode\_ci NOT NULL, `model_id` bigint(20) unsigned NOT NULL, PRIMARY KEY (`permission_id`,`model_id`,`model_type`), KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4\_unicode\_ci;

---

\-- Table structure for model\_has\_roles

---

DROP TABLE IF EXISTS `model_has_roles`; CREATE TABLE `model_has_roles` ( `role_id` bigint(20) unsigned NOT NULL, `model_type` varchar(190) COLLATE utf8mb4\_unicode\_ci NOT NULL, `model_id` bigint(20) unsigned NOT NULL, PRIMARY KEY (`role_id`,`model_id`,`model_type`), KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4\_unicode\_ci;

---

\-- Table structure for permissions

---

DROP TABLE IF EXISTS `permissions`; CREATE TABLE `permissions` ( `id` bigint(20) unsigned NOT NULL AUTO\_INCREMENT, `parent_id` int(11) NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL COMMENT '接口地址', `display_name` varchar(50) COLLATE utf8mb4\_unicode\_ci NOT NULL COMMENT '名称', `url` varchar(255) COLLATE utf8mb4\_unicode\_ci DEFAULT NULL COMMENT '页面路由', `guard_name` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL, `sort` smallint(6) NOT NULL DEFAULT '0' COMMENT '排序，数字越大越在前面', `icon` varchar(255) COLLATE utf8mb4\_unicode\_ci DEFAULT NULL, `created_time` timestamp NULL DEFAULT NULL, `updated_time` timestamp NULL DEFAULT NULL, `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0菜单，1按钮', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO\_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4\_unicode\_ci;

---

\-- Table structure for role\_has\_permissions

---

DROP TABLE IF EXISTS `role_has_permissions`; CREATE TABLE `role_has_permissions` ( `permission_id` bigint(20) unsigned NOT NULL, `role_id` bigint(20) unsigned NOT NULL, PRIMARY KEY (`permission_id`,`role_id`), KEY `role_has_permissions_role_id_foreign` (`role_id`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4\_unicode\_ci;

---

\-- Table structure for roles

---

DROP TABLE IF EXISTS `roles`; CREATE TABLE `roles` ( `id` bigint(20) unsigned NOT NULL AUTO\_INCREMENT, `name` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL, `description` varchar(200) COLLATE utf8mb4\_unicode\_ci DEFAULT NULL, `guard_name` varchar(255) COLLATE utf8mb4\_unicode\_ci NOT NULL DEFAULT 'web', `create_time` timestamp NULL DEFAULT NULL, `update_time` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO\_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4\_unicode\_ci;

\#安装方法

composer require wangcb/permission

\#User模型类加

class User extend Model{ use HasRole; }

$res = $user-&gt;getAllPermissions(); //获取所有权限

$user-&gt;can('/auth/add');//判断是否有权限

$res = $user-&gt;getMenu(); //获取权限菜单树

$user-&gt;getRoles();//获取用户角色

$user-&gt;clearRole();//删除用户所有角色

$user-&gt;roles(\[1,2,3\]);//给用户分配角色

###  Health Score

23

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

2

Last Release

2261d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/234f8347dba1af9c33f86daa5cf57da872b55105fbcd288b7eb4dda114ec917b?d=identicon)[wangcb](/maintainers/wangcb)

---

Top Contributors

[![wangcb](https://avatars.githubusercontent.com/u/19236668?v=4)](https://github.com/wangcb "wangcb (2 commits)")

### Embed Badge

![Health badge](/badges/wangcb-permission/health.svg)

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

###  Alternatives

[zoujingli/think-library

Core library and common services for ThinkAdmin

8374.7k20](/packages/zoujingli-think-library)[saithink/saiadmin

webman plugin

28412.2k1](/packages/saithink-saiadmin)[thans/tp-jwt-auth

thinkphp jwt auth composer

15494.7k6](/packages/thans-tp-jwt-auth)[casbin/think-authz

An authorization library that supports access control models like ACL, RBAC, ABAC for ThinkPHP.

27522.0k7](/packages/casbin-think-authz)[liliuwei/thinkphp-social

适用于thinkphp5.1和6.0的社会化登录扩展

7212.8k](/packages/liliuwei-thinkphp-social)[liliuwei/thinkphp-auth

适用于thinkphp6.0+的Auth权限扩展

3312.6k](/packages/liliuwei-thinkphp-auth)

PHPackages © 2026

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