Download the PHP package firebase/php-jwt without Composer
On this page you can find all versions of the php package firebase/php-jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
More information about firebase/php-jwt
Files in firebase/php-jwt
Short Description A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
Rated 4.44 based on 32 reviews
Informations about the package php-jwt
A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to RFC 7519.
Use composer to manage your dependencies and download PHP-JWT:
Optionally, install the
paragonie/sodium_compat package from composer if your
php is < 7.2 or does not have libsodium installed:
Example with RS256 (openssl)
Example with a passphrase
Example with EdDSA (libsodium and Ed25519 signature)
Using Cached Key Sets
CachedKeySet class can be used to fetch and cache JWKS (JSON Web Key Sets) from a public URI.
This has the following advantages:
- The results are cached for performance.
- If an unrecognized key is requested, the cache is refreshed, to accomodate for key rotation.
- If rate limiting is enabled, the JWKS URI will not make more than 10 requests a second.
When a call to
JWT::decode is invalid, it will throw one of the following exceptions:
All exceptions in the
Firebase\JWT namespace extend
UnexpectedValueException, and can be simplified
Casting to array
The return value of
JWT::decode is the generic PHP object
stdClass. If you'd like to handle with arrays
instead, you can do the following:
Run the tests using phpunit:
New Lines in private keys
If your private key contains
\n characters, be sure to wrap it in double quotes
and not single quotes
'' in order to properly interpret the escaped characters.