2016-12-27 68 views
2

来自作曲家I从laravel /流明创建了一个项目。我没有评论路由中间件流明5.3未定义变量:封闭

$app->routeMiddleware([ 
    'auth' => App\Http\Middleware\Authenticate::class, 
]);` 

我的路由添加了auth中间件。

$app->get('/', ['middleware'=>'auth'], function() use ($app) { 
    return $app->version(); 
}); 

我得到ErrorException in RoutesRequests.php line 656: Undefined variable: closure

我GOOGLE了这一点,它接缝中的问题5.2,但我有5.3下载。没有中间件,我得到Lumen (5.3.3) (Laravel Components 5.3.*)

+0

App \ Http \ Middleware \ AuthenticationMiddleware :: class –

+0

该类称为Authenticate not AuthenticationMiddleware。 – Varcor

回答

4

闭包应该是数组中的最后一项。将您的路线更改为:

$app->get('/', ['middleware'=>'auth', function() use ($app) { 
    return $app->version(); 
}]);