nagy/permissions-handler
最新稳定版本:v3.1.1
Composer 安装命令:
composer require nagy/permissions-handler
包简介
README 文档
README
Permissions-handler is an easy-to-use package for laravel 5 to manage users roles and permissions in an easy and attractive way
Features
Caching
Permissions Handler uses the caching feature on two levels
- Database Cache:
Permissions Handler uses the cache driver that configured in yourcache.phpfile for caching user permissions, roles for configurable time. - Annotation Cache:
Because of parsing the files against the annotations is costy; permission Hander caches the parsed annotations to avoid parsing it again. by default this features is disabled in the development environment and enabled in the production.
Gate Integration
PermissionsHandler register users permissions into the Gate, so you can easly use laravel built in can method.
Guard Support
PermissionsHandler doesn't depend on a specific model or guard, you can use whatever models or guards you need, PermissionsHandler will handle all.
Seeder
If you enabled the seeder option from the config/permissionsHandler.php file then Permissions Handler will save each created permission, role and role-permissions to fils to be able to seed it again in later time or share them with others.
Annotations
PermissionsHandler comes with an optinal awesome feature Annotations, it is based on Doctrine\Annotations. you can use it as the following:
use PermissionsHandler\Owns;
use PermissionsHandler\Roles;
use PermissionsHandler\Permissions;
.
.
.
/**
* @Permissions({"add-posts"})
*/
function store(Request $request) {
// your code here
}
/**
* @Roles({"admin"})
*/
function delete(Request $request) {
// your code here
}
/**
* @Owns(relation="posts", parameter="id")
*/
function update(Request $request) {
// your code here
}
As the above example, Permissions Handler comes with three types of annotations.
Permissions({"perm1"}):
only users that have perm1 permission can access this methodRoles({"role1"}):
only users that have role1 role can access this methodOwns(relation="posts", parameter="id"):
for example, if you are the owner of the post then only you whose can edit this post.Ownswill ensure that, just pass the relation and the parameter which PermissionsHandler will get the value from the Request accordingly.
Check the usage section for more features and details
License
Thanks to Ahmed Sorour <3
统计信息
- 总下载量: 83
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-04