2016-12-27 67 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(); 
}]);