1、修改composer.json文件,在 require中添加
"tymon/jwt-auth": "^1.0.0-rc.1"
2、然后使用命令行,进入项目目录,执行
composer update
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt',
'provider' => 'students',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\Admin\Admin::class,
],
'students' => [
'driver' => 'eloquent',
'model' => App\Models\Api\User::class,
],
],
3、转跳官网继续
4、将Auth::guard()修改为Auth::guard("api");
5、生成密钥
php artisan jwt:secret