ionghitun / jwt-token by ionghitun

Json web token generation and validation.
1,531
13
2
Package Data
Maintainer Username: ionghitun
Maintainer Contact: ionghitun@gmail.com (Ion Ghitun)
Package Create Date: 2019-12-15
Package Last Update: 2020-12-26
Language: PHP
License: MIT
Last Refreshed: 2024-04-22 15:03:20
Package Statistics
Total Downloads: 1,531
Monthly Downloads: 30
Daily Downloads: 1
Total Stars: 13
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

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.2

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 on 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.