PHP code example of jerrygaoyang / laravel-jwt
1. Go to this page and download the library: Download jerrygaoyang/laravel-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/ */
jerrygaoyang / laravel-jwt example snippets
use Jerry/JWT/JWT;
$payload = [
"user_id" => 1
];
$token = JWT::encode($payload);
print_r($token);
echo "<br>";
$payload = JWT::decode($token);
print_r($payload);
Route::middleware(['jwt'])->group(function () {
Route::get('/test2', 'TestController@test2');
});