joshbrw/laravel-permission-manager
Composer 安装命令:
composer require joshbrw/laravel-permission-manager
包简介
Laravel Permission Manager
README 文档
README
This package provides a simple way of registering permissions, organising them by group and then retrieving all permissions. These permissions can then be assigned to User/Role entities and used for Access Control logic.
Installation
- Install the package using
composer require joshbrw/laravel-permission-manager - If you're using Laravel 5.5 this is all that is required, the package will automatically load its' own Providers and Facades. If you're using Laravel 5.4, read on.
- Then register the Service Provider in
config/app.phpto ensure that the container bindings etc are loaded:'providers' => [ ... Joshbrw\LaravelPermissions\LaravelPermissionManagerServiceProvider::class, ] - You can then optionally register the
Permissionsfacade if you'd rather usePermission::registerPermissions()rather than using thePermissionManagerdirectly:'aliases' => [ ... 'Permissions' => Joshbrw\LaravelPermissions\Facades\Permissions::class, ] - You are now installed!
Registering Permissions
Permissions should usually be registered in the boot() method ophpuf a Service Provider - this ensures that this package has been able to register itself using it's own register() method first.
Using the Facade
The simplest way of registering permissions is using the Permissions facade. The following example registers the user.list and user.create permissions within the User group:
use Permissions; use Joshbrw\LaravelPermissions\Permission; class MyProvider extends ServiceProvider { public function boot() { Permissions::register('User', [ new Permission('user.list', 'List Users', 'This allows a User to list other Users.'), new Permission('user.create', 'Create Users', 'This allows a User to create another User.'), ]); } }
Using the Trait
You can also use the RegistersPermissions trait if you're not a fan of Facades, for example:
use Joshbrw\LaravelPermissions\Traits\RegistersPermissions; use Joshbrw\LaravelPermissions\Permission; class MyProvider extends ServiceProvider { use RegistersPermissions; public function boot() { $this->registerPermissions('User', [ new Permission('user.list', 'List Users', 'This allows a User to list other Users.'), new Permission('user.create', 'Create Users', 'This allows a User to create another User.'), ]); } }
joshbrw/laravel-permission-manager 适用场景与选型建议
joshbrw/laravel-permission-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.3k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 joshbrw/laravel-permission-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 joshbrw/laravel-permission-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-08