alexpts / php-jwt-service
Simple service for work with jwt tokens
1.1.0
2018-05-18 16:59 UTC
Requires
- php: ~7.2
- emarref/jwt: ^1.0
Requires (Dev)
- codeclimate/php-test-reporter: ^0.4.4
- phpunit/phpunit: ^7.1
This package is auto-updated.
Last update: 2024-10-15 02:17:14 UTC
README
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);