Lumen开发:简单实现auth用户认证

打开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

posted @ 2017-08-31 15:27  程序生(Codey)  阅读(1717)  评论(1编辑  收藏  举报