JWX Component | SocialConnect

JWX Component

Last Modified: 2019-07-27 Edit on GitHub

socialconnect/jwx is a library that implements:

Installation

You can install this package via composer:

$ composer require socialconnect/jwx:^1.0

Encode

<?php

$jwt = new \SocialConnect\JWX\JWT([
    'uid' => 5,
]);

$encodeOptions = new \SocialConnect\JWX\EncodeOptions();
$encodeOptions->setExpirationTime(600);

$token = $jwt->encode('TEST', 'HS256', $encodeOptions);
var_dump($token);

Decode

<?php

$decodeOptions = new \SocialConnect\JWX\DecodeOptions(['HS256'], 'TEST');
$token = \SocialConnect\JWX\JWT::decode($token, $decodeOptions);
var_dump($token);