Slim PHP Route in Middleware

后端 未结 3 782
Happy的楠姐
Happy的楠姐 2020-12-28 18:41

In Slim is it possible to get the current route within middleware?

class Auth extends \\Slim\\Middleware{
  public function call(){ 
    $currentRoute = $thi         


        
3条回答
  •  情深已故
    2020-12-28 19:03

    You should use app->request()->getPathInfo() instead of app->getRoute().

    class Auth extends \Slim\Middleware{
        public function call(){ 
            $currentRoute = $this->app->request()->getPathInfo();
        }
    }
    

提交回复
热议问题