Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

看网上说的 使用前置操作beforeActionList,但是不知道怎么用,所有的api接口 控制器之前都验证token 应该放在哪儿?

namespace appindexcontroller;
class Index extends hinkController
{
    protected $beforeActionList = [
        'checkToken',
    ];
    
    protected function checkToken()
    {
        echo 'checkToken<br/>';
    }
    
    public function index()
    {
        echo '测试';die();
    }
}

上边的index控制器里的beforeActionList 和checkToken()应该放在什么地方 如何在所有控制器调用?给个例子吧 初次接触 没闹明白 用的thinkphp5 多谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
576 views
Welcome To Ask or Share your Answers For Others

1 Answer

可以使用路由中间件


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...