天天看點

tp5.1 不使用Composer安裝vendor擴充包 直接安裝(從碼雲上直接下載下傳源碼包)vendor擴充包firebase php-jwt token驗證 API

不使用Composer安裝vendor擴充包

1、直接在 ​​git位址​​ 下載下傳 源碼包,解壓到\vendor\firebase這個位置

具體:\vendor\firebase\JWT\src\JWT.php

2、控制器代碼引用

不使用Composer安裝,不能直接引用的,是以用下面這種方法引用

require_once '../vendor/Firebase/JWT/BeforeValidException.php';
require_once '../vendor/Firebase/JWT/ExpiredException.php';
require_once '../vendor/Firebase/JWT/SignatureInvalidException.php';
require_once '../vendor/Firebase/JWT/JWT.php';
use \Firebase\JWT\JWT;      
$key = "example_key";
    $token = array(
      "iss" => "http://example.org",
      "aud" => "http://example.com",
      "iat" => 1356999524,
      "nbf" => 1357000000
    );

    /**
     * IMPORTANT:
     * You must specify supported algorithms for your application. See
     * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
     * for a list of spec-compliant algorithms.
     */
    $jwt = JWT::encode($token, $key);
    $decoded = JWT::decode($jwt, $key, array('HS256'));      

使用Composer安裝,會在\vendor\composer\installed.json中注冊,會寫入相關擴充包的資訊