1. Go to this page and download the library: Download fgsl/jwt library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fgsl / jwt example snippets
public function testBearerToken()
{
$jwt = new Jwt(['RS256','sha256'], 'JWT', 'newbraveworld.com', 'PT2H');
$bearerToken = $jwt->getBearerToken('foouser','baapassword',['role' => 'admin']);
$this->assertTrue(is_string($bearerToken));
$this->assertNotEmpty($bearerToken);
$payload = Jwt::getPayload($bearerToken);
$this->assertTrue(is_object($payload));
$this->assertEquals('foouser', $payload->sub);
$this->assertEquals('newbraveworld.com', $payload->iss);
$this->assertEquals('admin',$payload->role);
$this->assertFalse(Jwt::expired($bearerToken));
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.