PHP code example of rw / jwt

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

    

rw / 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);