1.安装 jwt-auth。
```
composer require tymon/jwt-auth 1.*@rc
```
2.将服务提供程序添加到配置文件中的`providers`数组,`config/app.php`如下所示:
```
'providers' => [
...
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
]
```
3.运行以下命令以发布程序包配置文件:
```
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
```
4.生成加密密钥:
```
php artisan jwt:secret
```
5.修改 config/auth.php
```
'guards' => [
'web' => [ 'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt', // 原来是 token 改成jwt 'provider' => 'users',
],
],
```