廢話不多說,直接進(jìn)入----|
1. 安裝拓展包
一给郊、集成dingo
①在composer.json的require字段中添加:"dingo/api":"1.0.*@dev"
②執(zhí)行:composer update
③在config/app.php注冊到providers數(shù)組:
'providers'=>[
Dingo\Api\Provider\LaravelServiceProvider::class,
]
④生成dingo配置文件config/api.php :
php artisanvendor:publish--provider="Dingo\Api\Provider\LaravelServiceProvider"
⑤.env添加基礎(chǔ)配置(四個即可):
API_STANDARDS_TREE=vnd
API_PREFIX=api
API_VERSION=v1
API_DEBUG=true
二牡肉、集成JWT
①在composer.json的require字段中添加:"tymon/jwt-auth":"0.5.*"
②執(zhí)行:composer update
③在config/app.php注冊到providers數(shù)組:
'providers'=>[
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
]
④注冊jwt門面:
'aliases'=>[
'JWTAuth'=> Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory'=> Tymon\JWTAuth\Facades\JWTFactory::class,
]
⑤生成jwt配置文件config/jwt.php :
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"
⑥生成jwt.php文件中數(shù)組的secret鍵成對應(yīng)的值:
php artisan jwt:generate