JwtEncoder
in package
Implements the JWT decoder and encoder.
Table of Contents
Methods
- __construct() : mixed
- decode() : object
- Decodes a JWT and applies verification steps.
- encode() : string
- Encodes an array or object as a JWT.
Methods
__construct()
public
__construct([JwkSet|null $keys = null ][, array<string|int, JwtValidator> $validators = [] ]) : mixed
Parameters
- $keys : JwkSet|null = null
-
Collection of keys that are allowed to verification.
- $validators : array<string|int, JwtValidator> = []
-
Collection of validators to run when decoding.
decode()
Decodes a JWT and applies verification steps.
public
decode(string $token[, array<string, mixed>|object|null $headers = null ][, bool $mergeHeaders = true ]) : object
Parameters
- $token : string
-
Token to be decoded.
- $headers : array<string, mixed>|object|null = null
-
JWT header section override.
- $mergeHeaders : bool = true
-
Whether $headers should be merged with the actual provided headers in the token (true), or replace them entirely (false).
Tags
Return values
object —Payload of the JWT.
encode()
Encodes an array or object as a JWT.
public
encode(array<string, mixed>|object $payload[, array<string, mixed>|object|null $headers = null ]) : string
Parameters
- $payload : array<string, mixed>|object
-
JWT payload section.
- $headers : array<string, mixed>|object|null = null
-
JWT header section.