https://github.com/not-empty/jwt-manager-php-lib
PHP library to manage JWT authentication
https://github.com/not-empty/jwt-manager-php-lib
Last synced: 2 months ago
JSON representation
PHP library to manage JWT authentication
- Host: GitHub
- URL: https://github.com/not-empty/jwt-manager-php-lib
- Owner: not-empty
- License: gpl-3.0
- Created: 2021-03-11T22:41:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-12-17T11:48:13.000Z (7 months ago)
- Last Synced: 2025-12-28T17:53:36.150Z (6 months ago)
- Language: PHP
- Size: 63.5 KB
- Stars: 14
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JWT Manager PHP
[](https://github.com/not-empty/jwt-manager-php-lib/releases)
[](https://codecov.io/gh/not-empty/jwt-manager-php-lib)
[](https://github.com/not-empty/jwt-manager-php-lib/actions/workflows/php.yml)
[](https://packagist.org/packages/kiwfy/jwt-manager-php)
[](https://packagist.org/packages/not-empty/jwt-manager-php-lib)
[](http://makeapullrequest.com)
[](https://github.com/not-empty/jwt-manager-php-lib/blob/master/LICENSE)
PHP library to manage JWT authentication
### Installation
[Release 8.0.0](https://github.com/not-empty/jwt-manager-php-lib/releases/tag/8.0.0) Requires [PHP](https://php.net) 8.4
[Release 7.0.0](https://github.com/not-empty/jwt-manager-php-lib/releases/tag/7.0.0) Requires [PHP](https://php.net) 8.3
[Release 6.0.0](https://github.com/not-empty/jwt-manager-php-lib/releases/tag/6.0.0) Requires [PHP](https://php.net) 8.2
[Release 5.0.0](https://github.com/not-empty/jwt-manager-php-lib/releases/tag/5.0.0) Requires [PHP](https://php.net) 8.1
[Release 4.0.0](https://github.com/not-empty/jwt-manager-php-lib/releases/tag/4.0.0) Requires [PHP](https://php.net) 7.4
[Release 3.0.0](https://github.com/not-empty/jwt-manager-php-lib/releases/tag/3.0.0) Requires [PHP](https://php.net) 7.3
[Release 2.0.0](https://github.com/not-empty/jwt-manager-php-lib/releases/tag/2.0.0) Requires [PHP](https://php.net) 7.2
[Release 1.0.0](https://github.com/not-empty/jwt-manager-php-lib/releases/tag/1.0.0) Requires [PHP](https://php.net) 7.1
The recommended way to install is through [Composer](https://getcomposer.org/).
```sh
composer require not-empty/jwt-manager-php-lib
```
### Usage
Generating a token
```php
use JwtManager\JwtManager;
$secret = '77682b9441bb7daa7a1fa6eb7522b689';
$context = 'test';
$expire = 30;
$renew = 10;
$jwtManager = new JwtManager(
$secret,
$context,
$expire,
$renew
);
$tokenGenerated = $jwtManager->generate('test');
var_dump($tokenGenerated);
```
Dedoce the token and return the data
```php
$result = $jwtManager->decodePayload($tokenGenerated);
var_dump($result);
```
Verify if token is valid
```php
$result = $jwtManager->isValid($tokenGenerated);
var_dump($result);
```
Check if a token is on time
```php
$result = $jwtManager->isOnTime($tokenGenerated);
var_dump($result);
```
Get the expiration time of a token
```php
$result = $jwtManager->getexpire($tokenGenerated);
var_dump($result);
```
Check if need to refresh a token
```php
$result = $jwtManager->tokenNeedToRefresh($tokenGenerated);
var_dump($result);
```
if you want an environment to run or test it, you can build and install dependences like this
```sh
docker build --build-arg PHP_VERSION=8.4-cli -t not-empty/jwt-manager-php-lib:php84 -f contrib/Dockerfile .
```
Access the container
```sh
docker run --name jwt-manager-php-lib -v ${PWD}/:/var/www/html -it not-empty/jwt-manager-php-lib:php84 bash
```
Verify if all dependencies is installed
```sh
composer install --no-dev --prefer-dist
```
and run
```sh
php sample/jwt-manager-sample.php
```
### Development
Want to contribute? Great!
The project using a simple code.
Make a change in your file and be careful with your updates!
**Any new code will only be accepted with all validations.**
To ensure that the entire project is fine:
First you need to building a correct environment to install all dependences
```sh
docker build --build-arg PHP_VERSION=8.4-cli -t not-empty/jwt-manager-php-lib:php84 -f contrib/Dockerfile .
```
Access the container
```sh
docker run --name jwt-manager-php-lib -v ${PWD}/:/var/www/html -it not-empty/jwt-manager-php-lib:php84 bash
```
Install all dependences
```sh
composer install --prefer-dist
```
Run all validations
```sh
composer check
```
**Not Empty Foundation - Free codes, full minds**