misaf/vendra-permission
Composer 安装命令:
composer require misaf/vendra-permission
包简介
Role and permission management for Vendra, built on top of Spatie Permission
README 文档
README
Role and permission management for Vendra applications.
Features
- Filament cluster on the
adminpanel for permission management - Role and permission CRUD resources
- Manage role-permission relations from role pages
- Tenant-scoped Pennant feature flags for module/resource access
- Feature toggle Artisan command per tenant
- Policy classes and enums for role/permission actions
- Translation files for
enandfa - Configurable
Gate::after()superadmin bypass role
Requirements
- PHP 8.2+
- Laravel 12
- Filament 5
- Livewire 4
- Pest 4
- Tailwind CSS 4
laravel/pennantmisaf/vendra-tenantmisaf/vendra-usermisaf/vendra-activity-logawcodes/filament-badgeable-columnmokhosh/filament-jalalispatie/laravel-permission
Installation
composer require misaf/vendra-permission
Publish Spatie permission config and migrations (if not already published in your app):
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag=permission-config php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag=permission-migrations php artisan migrate
Optional: publish module translations:
php artisan vendor:publish --tag=vendra-permission-translations
Optional: publish module config:
php artisan vendor:publish --tag=vendra-permission-config
If you use Pennant with the database driver, ensure Pennant storage is migrated in your application.
Configuration
If you want Spatie to use this module's models everywhere in your app, set config/permission.php:
'models' => [ 'permission' => Misaf\VendraPermission\Models\Permission::class, 'role' => Misaf\VendraPermission\Models\Role::class, ],
Superadmin bypass role is configurable in config/vendra-permission.php:
'super_admin_role' => env('VENDRA_PERMISSION_SUPER_ADMIN_ROLE', 'superadmin'),
The config key is super_admin_role (short and local to this file).
The env var remains VENDRA_PERMISSION_SUPER_ADMIN_ROLE (prefixed to avoid global collisions).
This value is used for both Gate::after() superadmin bypass and excluding that role from the roles table query.
Pennant feature behavior is configured in config/vendra-permission.php:
'features' => [ 'enabled' => env('VENDRA_PERMISSION_FEATURES_ENABLED', false), 'discover' => env('VENDRA_PERMISSION_FEATURES_DISCOVER', false), 'defaults' => [ 'vendra-permission.module-enabled' => false, 'vendra-permission.role-management' => false, 'vendra-permission.permission-management' => false, 'vendra-permission.bulk-role-assignment' => false, ], ],
When features.discover is enabled, the package calls:
Feature::discover('Misaf\\VendraPermission\\Features', __DIR__ . '/Features');
if the directory exists.
Filament
Resources are registered on the admin panel through PermissionPlugin:
- Roles
- Permissions
Navigation cluster: permissions
Access is feature-gated per tenant using Feature::for(Tenant::current()):
vendra-permission.module-enabledcontrols cluster accessvendra-permission.role-managementcontrols role resource accessvendra-permission.permission-managementcontrols permission resource accessvendra-permission.bulk-role-assignmentcontrols attach/detach role bulk actions
Permission Bulk Actions
AttachRolesAction and DetachRolesAction share role-resolution logic via:
Misaf\VendraPermission\Filament\Clusters\Resources\Permissions\Actions\Concerns\ResolvesSelectedRoles
The trait provides:
getRoleSelectOptions()for the roles multiselect options (name (guard_name))resolveRoleIdsByGuardFromPayload()to load selected roles withwhereKey(...)and group byguard_name
This keeps attach/detach behavior consistent and prevents cross-guard role operations when processing selected Permission records.
Pennant Features
Feature keys are defined in:
Misaf\VendraPermission\Enums\PermissionFeatureEnum
Resolver registration lives in:
Misaf\VendraPermission\Providers\PermissionServiceProvider::packageBooted()
Resolver behavior:
- non-tenant scopes are denied (
false) features.enabledmust be true- unresolved values fall back to
features.defaults
Feature map:
| Enum case | Feature key | Short key | Effect |
|---|---|---|---|
MODULE_ENABLED |
vendra-permission.module-enabled |
module-enabled |
Enables or hides the whole permissions cluster |
ROLE_MANAGEMENT |
vendra-permission.role-management |
role-management |
Enables or hides the roles resource |
PERMISSION_MANAGEMENT |
vendra-permission.permission-management |
permission-management |
Enables or hides the permissions resource |
BULK_ROLE_ASSIGNMENT |
vendra-permission.bulk-role-assignment |
bulk-role-assignment |
Enables or hides attach/detach role bulk actions |
Artisan Commands
Toggle tenant features with:
php artisan vendra-permission:feature {activate|deactivate} {feature|all} {tenant}
feature accepts:
- enum case name, e.g.
ROLE_MANAGEMENT - full key, e.g.
vendra-permission.role-management - short key, e.g.
role-management all
tenant accepts:
- tenant
id - tenant
slug
The command requires vendra-permission.features.enabled to be true.
Examples:
php artisan vendra-permission:feature activate module-enabled 1 php artisan vendra-permission:feature activate permission-management acme php artisan vendra-permission:feature deactivate all acme
Per-feature console reference (<tenant> can be tenant id or slug):
# MODULE_ENABLED php artisan vendra-permission:feature activate MODULE_ENABLED <tenant> php artisan vendra-permission:feature deactivate MODULE_ENABLED <tenant> # ROLE_MANAGEMENT php artisan vendra-permission:feature activate ROLE_MANAGEMENT <tenant> php artisan vendra-permission:feature deactivate ROLE_MANAGEMENT <tenant> # PERMISSION_MANAGEMENT php artisan vendra-permission:feature activate PERMISSION_MANAGEMENT <tenant> php artisan vendra-permission:feature deactivate PERMISSION_MANAGEMENT <tenant> # BULK_ROLE_ASSIGNMENT php artisan vendra-permission:feature activate BULK_ROLE_ASSIGNMENT <tenant> php artisan vendra-permission:feature deactivate BULK_ROLE_ASSIGNMENT <tenant>
Usage
Use this package's tenant feature flags and console command to control access in each tenant:
vendra-permission.module-enabledvendra-permission.role-managementvendra-permission.permission-managementvendra-permission.bulk-role-assignment
Role/permission CRUD and assignment semantics follow Spatie Permission. See: https://spatie.be/docs/laravel-permission
Development
composer analyse composer format
Keeping This README Updated
Update this file whenever these change:
composer.jsonrequirements- Pennant feature keys, defaults, or resolver behavior
- feature command signature or behavior
- Filament resources, pages, or cluster names
- Translation keys/files in
resources/lang - Authorization behavior in policies or
PermissionServiceProvider - Installation steps (especially migration/config behavior)
Testing
composer test
License
MIT. See LICENSE.
misaf/vendra-permission 适用场景与选型建议
misaf/vendra-permission 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 07 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「permission」 「filamentphp」 「vendra」 「misaf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 misaf/vendra-permission 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 misaf/vendra-permission 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 misaf/vendra-permission 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Filament plugin that integrates tabler icons, allowing you to use them seamlessly across Filament forms, tables, actions, and more.
jitone-ai is a powerful FilamentPHP plugin that integrates AI-powered features directly into your Filament forms.
This package provides a flexible way to add Role-based Permissions to Laravel 6.x
Send Notification to discord channel Webhook using native FilamentPHP Notification Facade class
This package provides a flexible way to add Role-based Permissions to Laravel
Alfabank REST API integration
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 34
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-11