d4v / php-jwt
D4v JWT is an implementation of firebase/php-jwt for Laravel
Installs: 173
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/d4v/php-jwt
Requires
- firebase/php-jwt: ^6.10
- illuminate/support: ^10 || ^11
This package is auto-updated.
Last update: 2026-01-10 12:28:10 UTC
README
Version 2.0.0 is compatible with Illuminate Support 10 and 11
This package provides a convenient way to use the lib firebase/php-jwt https://packagist.org/packages/firebase/php-jwt in Laravel.
- Call methods
encode()anddecode()via facade - Set up your configuration in a config file for convenience
Installation
composer req d4v/php-jwt
Configuration
php artisan vendor:publish --tag=config
The config file allows you to set issuer (from), secret (private key), algorythm (how to encrypt data) and ttl (time to live).
return [ 'issuer' => env('APP_URL', 'who-sent-the-token'), 'secret' => env('JWT_SECRET', 'your-key-here'), 'algo' => 'HS256', 'ttl' => 3600, // Expiration in seconds ];
This command can generate a key for you depending of your needs
php artisan key:generate --show
How to use
Simple way
In its simplest form, the lib can help you generate a JWT this fast:
use D4v\JWT\Facades\JWT; $token = JWT::encode(['sub'=> 1]);
You can also set your parameters entirely at runtime if needed:
payload = [
'iss' => 'https://mydomain.tld',
'sub' => 1,
'iat' => time(),
'exp' => time() + 60 * 10
];
JWT::encode($payload);
Call the decode() method to restore the data :
$decoded = JWT::decode($token);
More info about firebase/php-jwt can be found here : https://packagist.org/packages/firebase/php-jwt