1. Go to this page and download the library: Download anshu-krishna/php-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/ */
anshu-krishna / php-jwt example snippets
use Krishna\JWT\JWT;
$secret_key = 'your-secret';
$jwt = new JWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b2tlbi50ZXN0LmNvbSIsImF1ZCI6ImFwcC50ZXN0LmNvbSIsImlhdCI6MTY0Mzg5MTc1OCwibmJmIjoxNjQzODkxNzU4LCJleHAiOjE2NzI1MzQ4MDAsIm5hbWUiOiJBbnNodSBLcmlzaG5hIiwiY2l0eSI6IkJhbmdhbG9yZSIsImp0aSI6IjZmZGZhY2JkLWU1N2MtNDI1Yy1hNDBmLWM3NjQ5YjBkNDg0MSJ9.U7o6m77GP3oX_A_DgjgkS6U9rSLspPkOL_1dQLkr6QM');
var_dump(['JWT' => $jwt]);
echo "<hr />";
var_dump(['Verify' => $jwt->verify($secret_key)]);
use Krishna\JWT\Algo;
use Krishna\JWT\JWT;
$secret_key = 'your-secret';
$jwt = new JWT;
$jwt['name'] = 'AK';
$jwt['country'] = 'India';
$jwt->sign($secret_key, Algo::HS512);
echo "Token: ", $jwt, "<br><br>";
var_dump($jwt);
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.