PHP code example of laravel-shine / jwt

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

    

laravel-shine / jwt example snippets


try {
    $token = JWT::encode(['sub' => '1234567890', 'name' => 'John Smith'], $key256bit, 'HS256');
} catch (\Exception $e) {
    // encode error
}

try {
    $payload = JWT::decode($token, $key256bit);
    // $payload->sub == '1234567890'
} catch (\Exception $e) {
    // $e->getCode()
}