Use JWT::encode() to create a token and JWT::decode() to verify and parse it. When decoding, you must provide a Firebase\JWT\Key object specifying the key and the algorithm. By default, JWT::decode() returns a stdClass object; cast it to (array) if you require an associative array. You can also set JWT::$leeway to account for clock skew between servers.
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
$key = 'example_key_of_sufficient_length';
$payload = [
'iss' => 'example.org',
'aud' => 'example.com',
'iat' => 1356999524,
'nbf' => 1357000000
];
// Encode
$jwt = JWT::encode($payload, $key, 'HS256');
// Decode
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));
// To get an associative array:
$decoded_array = (array) $decoded;
// Account for clock skew (e.g., 60 seconds)
JWT::$leeway = 60;
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));