fdd/think-apidoc

Installs: 24

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Language:JavaScript

v2.0.3 2020-05-08 08:58 UTC

This package is auto-updated.

Last update: 2024-04-05 23:29:35 UTC


README

===============

fdd/think-apidoc 的运行环境要求PHP5.6+。

适用于 ThinkPHP5.1 自动生成API文档

主要新特性

  • 暂无

依赖

  • firebase/php-jwt

安装

composer require fdd/think-apidoc

使用

Demo

jwt使用

<?php
use FuDanDa\ApiDoc\Utils;

$key = "example_key";
$nowtime = time();
$expiration_time = 7200
$payload = [
    'iss'  => 'http://example.com', //签发者
    'aud'  => 'http://example.com', //jwt所面向的用户
    'iat'  => $nowtime,            //签发时间
    'nbf'  => $nowtime,            //在什么时间之后该jwt才可用
    'exp'  => $nowtime + $expiration_time, //过期时间-120分钟
    'sub'  => '',                  //主题
    'jti'  => '',                   //JWT ID用于标识该JWT
    'data' => $data,                //自定义信息
];

 //加密token:
 Utils::jwt_encode();

 //自定义
 /**
    * @param [array]  $data     用户信息
    * @param [string] $key      密钥
    * @param [int]    $expiration_time     过期时间
    * @param [string] $arithmetic     加密算法默认-HS256-[HS256,HS384,HS512,RS256,RS384,RS512]
    * @param [array]  $payload  配置
 */
Utils::jwt_encode($data, $key, $expiration_time, $arithmetic, $payload);
//助手函数
jwt_encode();



 //解密token:
 Utils::jwt_decode();

 //自定义
/**
* @param [array]  $token     jwt信息
* @param [string] $key      密钥
* @param [string]    $arithmetic     加密算法默认-HS256-[HS256,HS384,HS512,RS256,RS38RS512]
* @return string
*/
Utils::jwt_decode($token,  $key, $arithmetic);
 //助手函数
 jwt_decode();