官网的文档实在是太简单了 很多都没说
lumen下默认facades, cloquent, auth middleware, auth service都是不启用的!!
首先bootstrap/app.php下面
$app->withFacades();$app->withEloquent();
$app->routeMiddleware([
\'auth\' => App\Http\Middleware\Authenticate::class,
]);
$app->register(App\Providers\AuthServiceProvider::class);
这些前面的注释都要去掉
然后app/Http/routes.php要加上auth的middleware,如果该路由需要用户token认证进入的话
$app->group( [ // \'prefix\' => \'api/public/\', // \'namespace\' => \'App\Http\Controllers\Api\V3\', \'middleware\' => \'auth\', ], function () use ($app) { $app->get(\'hello\', function () use ($app) { return \'Hello, \' . $app->version(); }); } );