Looking to hire Laravel developers? Try LaraJobs

laravel-jwt maintained by lyue

Description
laravel jwt
Author
Last update
2020/12/23 08:16 (dev-main)
License
Links
Downloads
7

Comments
comments powered by Disqus

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'));