PHP code example of tumainimosha / token-helper

1. Go to this page and download the library: Download tumainimosha/token-helper 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/ */

    

tumainimosha / token-helper example snippets


use Tumainimosha\TokenHelper\TokenHelper;

// Generating jwt token. jwt is base64 encoded string
$jwt_string = (new TokenHelper)->getToken([
        'terminal_id' => $terminal->id,
        'token_id' => $tokenModel->id,
    ], 60 * 24 * 365 * 5);

     
// validating jwt token
$helper = new TokenHelper;
$status = $helper->validateToken($jwt_string);

if ($status === $helper::OK) {
   //handle success case
}

elseif ($status === $helper::EXPIRED) {
    //handle success case
}

else {
    // handle invalid token
}