Download the PHP package lgrevelink/php-simple-jwt without Composer
On this page you can find all versions of the php package lgrevelink/php-simple-jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lgrevelink/php-simple-jwt
More information about lgrevelink/php-simple-jwt
Files in lgrevelink/php-simple-jwt
Package php-simple-jwt
Short Description Simple package for creating JSON Web Tokens and using them in a PHP application.
License MIT
Informations about the package php-simple-jwt
PHP Simple JWT
Simple package for encoding and decoding JSON Web Tokens (JWT) and using them in a PHP application. More information can be found in RFC 7519.
Supported encryption methods;
HMAC | RSA | ECDSA | RSASSA-PSS |
---|---|---|---|
✅ HS256 | ✅ RS256 | ✕ ES256 | ✕ PS256 |
✅ HS384 | ✅ RS384 | ✕ ES384 | ✕ PS384 |
✅ HS512 | ✅ RS512 | ✕ ES512 | ✕ PS512 |
Installation
Example
Basic unsigned JWT but please, always sign your tokens.
Example with blueprints
Blueprints make generating and validating the already created tokens easier. They act as an abstract version of your actual token and will set up all the general claims when defined.
All date-related parameters in the blueprints are treated relative to the current time on the system.
Signing & verifying
HMAC
RSA
Through blueprints
The signature can also be attached to a TokenBlueprint
to keep everything contained in the blueprint instead of somewhere in application code.
All arguments after the first for TokenBlueprint::generateAndSign
and TokenBlueprint::sign
will be proxied to the TokenBlueprint::signature
method so they can be used there. All of the methods can be used seperately or combined to fit the implementation to your needs.
Parsing tokens
This part should be easy as 🍰. Just throw in your stringified token and it should be ready to use after parsing. If the given token or a part of the token cannot be properly parsed or decoded, an InvalidFormatException
is thrown.
Tests
Tests are written with PHPUnit and can be run via the following composer command;