Railgun JWT

Jwt
in package

JSON Web Token codec.

Table of Contents

Methods

decode()  : object
Decodes and verifies a JWT.
encode()  : string
Encodes a JWT.

Methods

decode()

Decodes and verifies a JWT.

public static decode(string $token[, array<string, mixed>|object|null $headers = null ][, bool $mergeHeaders = true ][, array<string, mixed> $options = [] ]) : 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).

$options : array<string, mixed> = []

Decoder options to use.

Tags
throws
InvalidArgumentException

If any of the argument types were not as expected.

Return values
object

Payload of the JWT.

encode()

Encodes a JWT.

public static encode(array<string, mixed>|object $payload[, array<string, mixed>|object|null $headers = null ][, array<string, mixed> $options = [] ]) : string
Parameters
$payload : array<string, mixed>|object

JWT payload section.

$headers : array<string, mixed>|object|null = null

JWT header section.

$options : array<string, mixed> = []

Encoder options to use.

Tags
throws
InvalidArgumentException

If any of the argument types were not as expected.

Return values
string

        
On this page

Search results