php artisan route:list 未根据请求设置 RuntimeException 会话存储
php artisan route:list RuntimeException Session store not set on request
当我通过 doc 命令检查路由列表时:
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;
}
}
}
在控制器中使用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;
}
}
}
当我通过 doc 命令检查路由列表时:
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;
}
}
}
在控制器中使用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;
}
}
}