php artisan route:list RuntimeException未根据请求设置会话存储

时间:2016-07-14 15:22:00

标签: laravel session routes artisan

当我通过命令表格doc检查路线列表时:

php artisan route:list //RuntimeException:  Session store not set on request.

我发现在session()函数中应该更好地使用辅助函数$request->session()而不是Controller __contract

class SomeController extends Controller
{
    public function __construct(Request $request)
    {
        //use $request->session()->has($var) will occur the exception as this post said.
        if (session()->has($var)) {          
        //do something;
    }
}

}

1 个答案:

答案 0 :(得分:2)

控制器中使用session()代替$request->session(),例如:

class SomeController extends Controller
{
    public function __construct(Request $request)
    {
        //use $request->session()->has($var) will occur the exception as this post said.
        if (session()->has($var)) {          
        //do something;
        }
    }
}