ezijing / ezijing-permission-plugins
清控紫荆hyperf权限插件
V1.0.6
2022-03-01 11:25 UTC
Requires
- php: >=7.2
- ext-json: *
- ext-swoole: >=4.5
- hyperf/config: 2.2.*
- hyperf/di: 2.2.*
- hyperf/framework: 2.2.*
- hyperf/guzzle: 2.2.*
- hyperf/utils: 2.2.*
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- hyperf/devtool: ~2.2.0
- hyperf/ide-helper: ~2.2.0
- hyperf/testing: ~2.2.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^0.12
- swoole/ide-helper: ^4.5
Suggests
- ext-json: Required to use JSON.
- ext-openssl: Required to use HTTPS.
README
使用说明
1、下载composer包
> composer require ezijing/ezijing-permission-plugins -vvv
2、发布配置
> php bin/hyperf.php vendor:publish ezijing/ezijing-permission-plugins
3、更改配置文件
<?php declare(strict_types=1); return [ 'HOST' => env('PERMISSION_HOST', ''), 'SECRET_ID' => env('PERMISSION_SECRET_ID', ''), 'SECRET_KEY' => env('PERMISSION_SECRET_KEY', ''), 'API' => [ 'ROUTES' => [ 'METHOD' => 'GET', 'API' => '/api/v1/user/routes', 'DESC' => '获取当前登录用户所有被允许访问的路由(后端使用,调用是强制Cookie写入TGC)', ], ], ];
在项目根目录霞配置.env
文件
PERMISSION_HOST=https://permissions-api.ezijing.com PERMISSION_SECRET_ID=XXXX PERMISSION_SECRET_KEY=XXXX
4、通过注解方式使用
<?php declare(strict_types=1); namespace App\Controller\Admin\V3\System; use App\Controller\BaseController; use Ezijing\PermissionPlugins\Middlewares\PermissionMiddleware; use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\Middleware; use Hyperf\HttpServer\Annotation\Middlewares; /** * 使用手册管理. * * @Controller(prefix="admin/v3/system") * @Middlewares({ * @Middleware(PermissionMiddleware::class) * }) * */ class UserManualController extends BaseController {}