PHP code example of not-empty / jwt-manager-php-lib

1. Go to this page and download the library: Download not-empty/jwt-manager-php-lib 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/ */

    

not-empty / jwt-manager-php-lib example snippets


use JwtManager\JwtManager;
$secret = '77682b9441bb7daa7a1fa6eb7522b689';
$context = 'test';
$expire = 30;
$renew = 10;
$jwtManager = new JwtManager(
    $secret,
    $context,
    $expire,
    $renew
);
$tokenGenerated = $jwtManager->generate('test');
var_dump($tokenGenerated);

$result = $jwtManager->decodePayload($tokenGenerated);
var_dump($result);

$result = $jwtManager->isValid($tokenGenerated);
var_dump($result);

$result = $jwtManager->isOnTime($tokenGenerated);
var_dump($result);

$result = $jwtManager->getexpire($tokenGenerated);
var_dump($result);

$result = $jwtManager->tokenNeedToRefresh($tokenGenerated);
var_dump($result);
sh
php sample/jwt-manager-sample.php