PHP code example of eru123 / jwt

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

    

eru123 / jwt example snippets




ru123\jwt\JWT;

$payload = [
    'hello' => 'world',
];
$key = 'secret';
$token = JWT::encode($payload, $key); // eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJoZWxsbyI6IndvcmxkIn0.bqxXg9VwcbXKoiWtp-osd0WKPX307RjcN7EuXbdq-CE
$decoded = JWT::decode($token, $key); // {"hello":"world"}