前言
玩Lumen真的会遇到很多坑,jwt-auth就是其中之一,首先其对Lumen的配置教程比较少,其次可能是本人对Laravel和Lumen还不是太熟悉导致。
成功配置好Lumen+jwt-auth的时候可能还会出现问题:
|
|
解决办法
在
bootstrap/app.php
中添加如下代码:12345678910111213$app->singleton(Illuminate\Auth\AuthManager::class,function ($app) {return $app->make('auth');});$app->singleton(Illuminate\Cache\CacheManager::class,function ($app) {return $app->make('cache');});$app->register(App\Providers\AppServiceProvider::class);修改
app/Providers/AppServiceProvider.php
,在register
方法中添加如下代码:1234$this->app->singleton('Illuminate\Contracts\Routing\ResponseFactory', function ($app){return new ResponseFactory($app['Illuminate\Contracts\View\Factory'], $app['Illuminate\Routing\Redirector']);});大功告成了,问题已经解决,可以愉快地开启你的Lumen+jwt之旅!
12345678910111213$app->singleton(Illuminate\Auth\AuthManager::class,function ($app) {return $app->make('auth');});$app->singleton(Illuminate\Cache\CacheManager::class,function ($app) {return $app->make('cache');});$app->register(App\Providers\AppServiceProvider::class);