- time: documentation ( source)
<?php
use \Firebase\JWT\JWT;
//function to generate JWT
function generateJWT () {
$key = 'key';
$secret = 'secret';
$token = array(
"iss" => $key,
// The benefit of JWT is expiry tokens, we'll set this one to expire in 1 minute
"exp" => time() + 60
);
return JWT::encode($token, $secret);
}
echo generateJWT();