PHP code example of ltxlong / thinkphp6-auth

1. Go to this page and download the library: Download ltxlong/thinkphp6-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/ */

    

ltxlong / thinkphp6-auth example snippets



use think\auth\Auth;
use app\BaseController;

class adminBaseController extends BaseController
{
    public function _initialize()
	  {
        parent::initialize();
        $controller = request()->controller();
        $action = request()->action();
        $auth = new Auth();
        if(!$auth->check($controller . '/' . $action, session('uid'))){
          $this->error('你没有权限访问');
        }
    }