我想在刀片模板中使用一段简单的代码:
@if($errors->has())
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
@endif
但是为了使用$ errors,我读到了需要使用web
中间件的地方,所以我也设置了这个路径:
'middleware' => ['web']
并补充说:
$app->register(Illuminate\Session\Middleware\StartSession::class);
$app->register(Illuminate\View\Middleware\ShareErrorsFromSession::class);
到app.php
但是现在,当我打开这条路线时,我收到了这个错误:
lumen.ERROR: exception 'ErrorException' with message 'Argument 1 passed to Illuminate\Session\Middleware\StartSession::__construct() must be an instance of Illuminate\Session\SessionManager, instance of Laravel\Lumen\Application given
答案 0 :(得分:0)
解决方案是将此添加到app.php:
$app->middleware([
Illuminate\Session\Middleware\StartSession::class,
Illuminate\View\Middleware\ShareErrorsFromSession::class
]);