1. Go to this page and download the library: Download psecio/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/ */
= "example_key";
$header = new \Psecio\Jwt\Header($key);
$jwt = new \Psecio\Jwt\Jwt($header);
$jwt->custom('foobar', 'custom-claim');
// Or, you can add more than one at the same time with an array
$jwt->custom(array(
'custom-claim' => 'foorbar',
'key1' => 'value1'
));
$result = $jwt->encode();
echo 'ENCODED: '.print_r($result)."\n\n";
echo 'DECODED: '.var_export($jwt->decode($result), true);
$key = openssl_pkey_get_private('file://'.__DIR__.'/private.pem', 'test1234');
$header = new \Psecio\Jwt\Header($key);
$header->setAlgorithm('RS256');
// or you can define the hash algorithm on the init too:
$header = new \Psecio\Jwt\Header($key, 'RS256');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.