PHP code example of cuarb / tp6-jwt
1. Go to this page and download the library: Download cuarb/tp6-jwt library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cuarb / tp6-jwt example snippets
use cuarb\jwt\facade\JWTAuth;
$token = JWTAuth::builder(['uid' => 1]);//参数为用户认证的信息,请自行添加
JWTAuth::auth();//token验证
JWTAuth::refresh();//刷新token,会将旧token加入黑名单
$tokenStr = JWTAuth::token(); //可以获取请求中的完整token字符串
$payload = JWTAuth::auth(); //可验证token, 并获取token中的payload部分
$uid = $payload['uid']; //可以继而获取payload里自定义的字段,比如uid
shell
$ php think jwt:create