zakariajawas/permissions-generator
Composer 安装命令:
composer require zakariajawas/permissions-generator
包简介
Generate default permissions for spatie permissions package according to your models
README 文档
README
Generate basic permissions for spatie permissions package for all your models at once using one artisan command.
This package contains a GeneratePermissionsProvider that you can use in your packages to easily register the config file and the artisan command.
What It Does
If you are using spatie permissions package, you need to create permissions for roles manually, common permissions for all models are access (list), create, edit and delete
This package will create all the basic permissions for all models using only one artisan command.
php artisan permissions:generate
If you have the following models [Category, Product] as example, after running the generate command, the following rows will be inserted in your permissions table
list category
create category
edit category
delete category
list product
create product
edit product
delete product
Note: You can modify some values inside the config file, check Working with config file section below.
Getting started
Installation
composer require zakariajawas/permissions-generator
You should publish the config/permissionsgenerator.php config file with:
php artisan vendor:publish --provider="ZakariaJawas\PermissionsGenerator\Providers\GeneratePermissionsProvider"
Working with config file
In config/permissionsgenerator.php file you can modify the following values.
- Modify this value to add, update or delete a permission.
These are the basic permissions.
'permissions' => ['list', 'create', 'edit', 'delete']
For example to add access permission and change edit to update you can do this.
'permissions' => ['access', 'list', 'create', 'update', 'delete']
- By default the package will generate the permissions for all project models, you might want to exclude specific one or more models so you can do this.
'exclude' => [ App\Models\Session::class, //no permissions generated for Session model ],
- If you have static permissions which are not related to models for example export to pdf or access all data or maybe a page which doesn't have a model you can add these permisisons in $staticPermissions array
'staticPermissions' => ['export pdf', 'access dashboard']
Note:-
- You have to add the full model class path.
- You don't have to exclude other packages models, this package won't create permissions for them.
- Default permissions name is
permission + model name, if you want to add a prefix you can specify it here.
'prefix' => 'can',
Result will be can create product instead of create product
License
The MIT License (MIT). Please see License File for more information.
Author
Zakaria Jawas @zakariajawas
Getting help
If you spot a problem you can open an issue on the Github page, or alternatively, you can contact me via jawas.zakaria@gmail.com
Support the library by posting in
If you enjoy it, please make this library better 👍
zakariajawas/permissions-generator 适用场景与选型建议
zakariajawas/permissions-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60 次下载、GitHub Stars 达 6, 最近一次更新时间为 2022 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「generator」 「php」 「laravel」 「permissions」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zakariajawas/permissions-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zakariajawas/permissions-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zakariajawas/permissions-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
PHP module for MySql database
统计信息
- 总下载量: 60
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-08