打開bootstrap/app.php,取消下面兩段代碼的注釋,
$app->middleware([ App\Http\Middleware\ExampleMiddleware::class ]); $app->routeMiddleware([ 'auth' => App\Http\Middleware\Authenticate::class, ]);
打開router/web.php,加入以下路由代碼,
$app->group(['middleware' => 'auth'], function ($app){ $app->get('hello', function() { echo 'hello, world'; }); });
訪問 域名/hello,顯示 hello, world。
https://laravel-china.org/docs/lumen/5.2/authentication/1863