lyue / laravel-jwt
laravel jwt
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/lyue/laravel-jwt
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'));