thinkphp6的插件扩展:http://sites.thinkphp.cn/1556332
我用的是https://github.com/wenhainan/thinkphp6-auth这个权限验证
1.按步骤创建数据表,
用户表:
权限表:
角色表:
用户所属角色表:
2.composer代码下来
,
composer代码下来后会在config文件多出一个auth.php, 在里面可以更改表的名字
3.composer下来后
3.使用
<?phpnamespace app\admin\controller;use app\BaseController;use think\facade\View;use think\wenhainan\Auth;class AdminBase extends BaseController{public function initialize(){$controller = strtolower(request()->controller());$action = strtolower(request()->action());$auth = Auth::instance();// dump($auth);exit;// 检测权限if(!$auth->check($controller.'-'.$action,1)){// 第一个参数是规则名称,第二个参数是用户UID//有显示操作按钮的权限 dump('您没有权限访问');}}}