firebase/php-jwt
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The Firebase/PHP-JWT is a simple library designed to encode and decode JSON Web Tokens (JWT) in PHP, conforming to the RFC 7519 specification. It serves the role of ensuring secure transmission of information between parties as JSON objects. This information is digitally signed, confirming the authenticity and reliability of the sent information.
To use Firebase/PHP-JWT in your PHP project, first install it via Composer by using the command:
composer require firebase/php-jwt
Once installed, it gets employed in your PHP code. Below is a basic usage example for encoding and decoding a payload:
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
$key = 'example_key';
$payload = [
'iss' => 'http://example.org',
'aud' => 'http://example.com',
'iat' => 1356999524,
'nbf' => 1357000000
];
$jwt = JWT::encode($payload, $key, 'HS256');
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));
print_r($decoded);
Apart from basic usage, it supports multiple advanced functionalities such as using RSA encryption (RS256), generating JWT with a passphrase, using EdDSA (libsodium and Ed25519 signature), multiple keys, JSON Web Key Sets (JWKs), and cached key sets among others.
Firebase/PHP-JWT documentation doesn't have a dedicated website. Instead, one can find all needed instructions and usage examples directly on the project's GitHub repository. The readme file of this repository contains detailed instructions on how to install and use Firebase/PHP-JWT, including various usage examples for different scenarios.