Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

ionghitun/jwt-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest Stable Version Build Status Total Downloads Scrutinizer Code Quality License

Jwt Token

Json web token generation and validation.

Instalation notes

$ composer require ionghitun/jwt-token

Dependencies

  • php >= 7.3

Documentation:

You need to add JWT_SECRET to your .env file.

Import Jwt from IonGhitun\JwtToken

  • use Jwt::generateToken($payload) to generate a token, $payload should be an array.
  • use Jwt::validateToken($token) to validate a token.

Validity of the token is default one day. It can be overwritten by adding expiration to $payload:

    $payload['expiration'] = Carbon::now()->addDay()->format('Y-m-d H:i:s');

In case $token is not a valid Jwt token, expired or could not verify signature with secret a IonGhitun\JwtToken\Exceptions\JwtException will be thrown on validateToken method.

Happy coding!

About

Json web token generation and validation.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages