PHP code example of revenuewire / jwt

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

    

revenuewire / jwt example snippets




$jwt = new \RW\JWT\Token();
$jwt->setIssuer('carambola')
    ->setAudience('jackfruit')
    ->setSecret("super-01-secret")
    ->setPayload(array("hello" => "world"))
    ->setExpiry(5);
$token = $jwt->getToken();
echo $token . "\n";

$validator = \RW\JWT\Token::init($token);
$payload = $validator->setSecret("super-01-secret")
                ->validate()
                ->getPayload();
print_r($payload);