alexpts/php-jwt-service

Simple service for work with jwt tokens

1.1.0 2018-05-18 16:59 UTC

This package is auto-updated.

Last update: 2024-10-15 02:17:14 UTC


README

Build Status Code Coverage Code Climate Scrutinizer Code Quality

Simple service with work JWT tokens.

Install

composer require alexpts/php-jwt-service

Demo

<?php
use Emarref\Jwt\Algorithm\Hs512;
use PTS\JwtService\JwtService;

$secret = 'sa#FD423efdl#';
$alg = new Hs512($secret);

$service = new JwtService($alg);
$jwtToken = $service->encode(['userId' => 1]);

// with auto expire
$service->setExpire(3600);
$jwtToken2 = $service->encode(['userId' => 1]);


$jwtToken3 = 'some string jst token';
$tokenObject = $service->decode($jwtToken3);