Download the PHP package jerrygaoyang/laravel-jwt without Composer
On this page you can find all versions of the php package jerrygaoyang/laravel-jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jerrygaoyang/laravel-jwt
More information about jerrygaoyang/laravel-jwt
Files in jerrygaoyang/laravel-jwt
Package laravel-jwt
Short Description jwt auth for encode decode and token expire_in authenticate
License MIT
Informations about the package laravel-jwt
laravel-jwt
Installation
- First: Require this package with composer using the following command
composer require jerrygaoyang/laravel-jwt
- Second: add the service provider to the providers array in config/app.php
Jerry\JWT\Providers\JWTProvider::class
- Last: publish jwt config to laravel config path
php artisan vendor:publish --provider="Jerry\JWT\Providers\JWTProvider"
Configuration
- add the JWT middleware to the routeMiddleware array in app/Http/Kenel.php
'jwt' => \Jerry\JWT\Middleware\JWTMiddleware::class,
- JWT config in config/jwt.php
User Guide
encode and decode
http api process for laravel
-
First: http request must have header
-
Second: laravel route use middleware jwt
- Last: user request get jwt decode payload in your laravel controller
Exception (global for api)
you can copy below code to your Laravel app/Exceptions/handler.php render function;
it's easy to change the token exception for us;
it's easy to change the return data for api response.
of course, we should:
use Jerry\JWT\Exceptions\TokenFormatException;
use Jerry\JWT\Exceptions\TokenExpiredException;
use Jerry\JWT\Exceptions\TokenForwardException;
use Jerry\JWT\Exceptions\PayloadFormatException;