Encode and decode JSON Web Tokens in PHP
open sourceBSD-3-Clausefree
PHP-JWT (the Composer package firebase/php-jwt, now maintained under Google's googleapis organization) is a library for encoding and decoding JSON Web Tokens in PHP, conforming to RFC 7519. It supports JSON Web Signature, JSON Web Keys and the HS, RS, ES and PS families of algorithms plus EdDSA (Ed25519), can parse JWK sets, and can fetch and cache a JWKS from a public URL with its CachedKeySet class. It handles signed tokens only, not encrypted ones.
Problems it solves
- verify a JWT in a PHP app
- issue signed JSON Web Tokens from PHP
- validate tokens against a provider's JWKS endpoint in PHP
Features
- Encodes and decodes JWTs per RFC 7519
- HS256/384/512, RS256/384/512, ES256/384, PS256 and EdDSA (Ed25519)
- Parses JSON Web Key sets
- Fetches and caches JWKS from a public URL
Limitations
- Supports only signed JWTs (JWS): encrypted JWTs (JWE) aren't supported1
Alternatives
The same job
These do what PHP-JWT does.
- lcobucci/jwt Framework-agnostic PHP library to issue, parse and validate JSON Web Tokens
- jwt-auth JSON Web Token authentication for Laravel and Lumen
- OAuth 2.0 Client PHP League's base library for OAuth 2.0 sign-in with any provider
