PHP code example of zhujinkui / auth
1. Go to this page and download the library: Download zhujinkui/auth library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zhujinkui / auth example snippets
namespace app\common\controller;
use think\Controller;
class Base extends Controller
{
public function _initialize()
{
// 自动动态获取URL需要自行处理
$url = "Admin/Index/index";
// 自动动态获取用户UID需要自行处理
$uuid = 1;
//实力化权限类库
$auth = new \think\Auth();
if (!$auth->check($url, $uuid)) {
$this->error('没有权限!');
}
}
}
$auth->check('rule1,rule2',uid);