Download the PHP package mdt-star/nexus without Composer
On this page you can find all versions of the php package mdt-star/nexus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download mdt-star/nexus
More information about mdt-star/nexus
Files in mdt-star/nexus
Download mdt-star/nexus
More information about mdt-star/nexus
Files in mdt-star/nexus
Vendor mdt-star
Package nexus
Short Description Laravel 核心权限模块 - 提供功能权限控制、菜单管理、数据范围策略、动态配置等基础设施能力
License MIT
Package nexus
Short Description Laravel 核心权限模块 - 提供功能权限控制、菜单管理、数据范围策略、动态配置等基础设施能力
License MIT
Please rate this library. Is it a good library?
Informations about the package nexus
Nexus — Laravel 核心权限枢纽
Laravel 核心权限模块,提供功能权限控制、菜单管理、数据范围策略、动态配置等基础设施能力。
功能特性
- 功能权限控制 - 基于 tag 的权限节点体系,支持树形层级结构
- 菜单管理 - 菜单发布池,支持动态路径拼接和用户自定义覆盖
- 用户桌面 - 支持用户自定义桌面布局,从菜单池拖拽绑定
- 数据范围策略 - 可扩展的数据范围控制,支持模型白名单和字段白名单
- 动态配置 - 运行时动态配置管理,支持类型自省
- 模型权限矩阵 - 模型级别的读写删权限控制
- 模块化集成 - 第三方模块即装即用,自动注册权限和菜单
- 多国语言 - 权限名称通过语言包匹配 tag,不存储在数据库
安装
配置
发布配置文件:
发布语言文件:
快速开始
1. 权限同步
同步单个模块的权限和菜单:
2. 路由权限控制
使用 Route::auth() 路由组自动注入权限校验:
中间件参数格式:auth.tag:{tag},{guard?}
3. 路由挂载系统(Mount System)
路由挂载系统提供了一种声明式、可继承的路由组织方式。通过预定义"挂载点",快速注册带有统一前缀和中间件能力的路由组。
基础使用:
快捷宏(自动注册):
扩展自定义 Mount:
4. 数据范围 Trait
在模型中使用数据范围控制:
5. 模型权限控制
在模型中使用模型访问权限:
6. 功能权限接口
模型实现 HasPermission 接口即可获得 tag 权限校验能力:
User 模型已内置实现,支持穿透 Role 合并 tag:
第三方模块集成
第三方模块在 composer.json 中声明权限和菜单:
核心概念
| 概念 | 说明 |
|---|---|
| Permission | 功能权限节点,通过 tag 标识 |
| Package | 模块包,关联一组权限 |
| Permissionable | 多态关联,将 tag 授予 User/Role(原 ModelHasPermission) |
| Role | 角色组,支持 tag 穿透到用户 |
| Menu | 菜单发布池,前端可用的菜单项 |
| Desktop | 用户桌面,支持自定义布局 |
| DataScope | 数据范围策略,控制查询数据边界 |
| DynamicConfig | 动态配置,支持运行时修改 |
| ModelAccess | 模型级别的读写删权限控制 |
架构设计
权限校验流程
数据范围流程
设计原则
- 零物理外键 - 逻辑关联,表结构独立
- Laravel 生态兼容 - 遵循命名规范,使用生态工具
- 配置驱动 - 静态配置放 config,动态配置放数据库
- 模块化 - 第三方模块即装即用
- 单一职责 - 每个类只做一件事
测试
当前测试覆盖:117 个测试,232 个断言,涵盖 HasPermissionTrait、PermissionSyncer、Package、PermissionDeniedException、User 穿透 Role 集成测试、Mount 路由挂载系统、Desktop/DesktopItem API 集成测试。
许可证
MIT
All versions of nexus with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
illuminate/support Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0
illuminate/http Version ^10.0|^11.0
illuminate/auth Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0
illuminate/http Version ^10.0|^11.0
illuminate/auth Version ^10.0|^11.0
The package mdt-star/nexus contains the following files
Loading the files please wait ...