PHP code example of kiwfy / jwt-manager-php

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

    

kiwfy / jwt-manager-php 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