安裝
1 | composer create-project --prefer-dist laravel/laravel laravel-jwt-sandbox |
配置
config/app.php
1 | // aliases |
app/HTTP/Kernel.php
1 | // routeMiddleware |
1 | php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider" |
實作
AuthenticateController
1 | public function authenticate(Request $request) |
route/api.php
設定 route
1 | Route::post('/login', 'AuthenticateController@authenticate'); |
呼叫方式
取得 Token
1 | POST http://localhost:8080/api/login |
驗證 JWT token
1 | POST http://localhost:8080/api/jwt/check |
參考資料