PHP code example of henryeticom / php-jwt

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

    

henryeticom / php-jwt example snippets



use HenryEticom\PHPJWT\JWT;

$secret = 'your-secret-key';

$headers = array(
    'alg' => 'ES256',
    'typ' => 'JWT'
);

$payload = array(
    'sub'       => 1,
    'name'      => 'Test',
    'exp' => (time() + (60 * 60))
);

$jwt = JWT::encode($headers, $payload, $secret);

var_dump($jwt);


use HenryEticom\PHPJWT\JWT;

$jwt = 'response-from-encode';

$secret = 'your-secret-key';

$decode = JWT::decode($jwt, $secret);

var_dump($decode);


composer