【问题标题】:php artisan route:list RuntimeException Session store not set on requestphp artisan route:list RuntimeException 会话存储未按请求设置
【发布时间】:2016-11-17 14:31:05
【问题描述】:

当我通过命令形式文档检查路由列表时:

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

我发现在 Controller __contract 函数中使用辅助函数 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;
    }
}

}

【问题讨论】:

  • 格式化的内嵌内容。

标签: laravel session routes laravel-artisan


【解决方案1】:

控制器中使用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;
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-08
    • 2016-03-30
    • 2023-03-22
    • 2020-08-24
    • 2017-03-13
    • 2020-11-28
    • 2018-04-12
    • 2017-09-30
    相关资源
    最近更新 更多