PHP code example of vakata / jwt
1. Go to this page and download the library: Download vakata/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/ */
vakata / jwt example snippets
php
$token = new \vakata\jwt\JWT();
$token
->setClaim("key", "value")
->setExpiration("+30 days")
->setIssuer("System")
->sign("secretKey");
$stringified = (string)$token;
$parsed = \vakata\jwt\JWT::fromString($stringified);
var_dump($parsed->isValid()); // true
var_dump($parsed->isSigned()); // true
var_dump($parsed->verifyHash("secretKey")); // true
var_dump($parsed->getClaim("key")); // "value"