PHP code example of automattic / jetpack-jwt

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

    

automattic / jetpack-jwt example snippets


$payload = array(
    'hello' => 'world'
);
$secret = 'abc';

$jwt_string = Automattic/Jetpack/JWT::encode( $payload, $secret );

try{
    $descripted = Automattic/Jetpack/JWT::decode( $jwt_string, $secret );
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

echo $descripted->hello;
// prints "world"
bash
composer test-php
bash
composer test-php packages/jwt