lyue / laravel-jwt
laravel jwt
v1.0
2020-12-23 07:16 UTC
README
JWT plugin for laravel
is maybe the simplest JWT plugin
Installation
composer require lyue/laravel-jwt
config
php artisan vendor:publish
and choose the lyue/laravel-jwt,it will create a config file jwt.php in config path
//provider
Lyue\LaravelJwt\JwtProvider::class
//facade
'Jwt' => \Lyue\LaravelJwt\JwtFacade::class
set it into provider and facade of config/app.php
Example
get a token
$payload = [
'user_id'=>123,
'iss'=>'www.baidu.com'
];
$token = \Jwt::getToken($payload);
check token
\Jwt::verifyToken($token);
get payload
$payload = \Jwt::getPayload();
get payload by key
$user_id = \Jwt::getPayload('user_id');
you can set key=>value as session
\Jwt::set('username',$username);
var_dump(\Jwt::get('username'));