PHP code example of dh2y / think-auth
1. Go to this page and download the library: Download dh2y/think-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/ */
dh2y / think-auth example snippets
use think\Controller;
use think\auth\Auth;
class Base extends Controller
{
public function _initialize()
{
$controller = request()->controller();
$action = request()->action();
$auth = new Auth();
if(!$auth->check($controller . '-' . $action, session('uid'))){
$this->error('你没有权限访问');
}
}
}
$auth->check('rule1,rule2',uid);