PHP code example of free2er / jwt

1. Go to this page and download the library: Download free2er/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/ */

    

free2er / jwt example snippets


use Free2er\Jwt\KeyFactory;

$factory = new KeyFactory();
$factory->create('/path/to/private.key');
$factory->create('/path/to/public.key');

use Free2er\Jwt\TokenFactory;

$factory = new TokenFactory();
$factory->create(['aud' => 'client', 'sub' => 'user'], '/path/to/private.key');

use Free2er\Jwt\TokenValidator;

$validator = new TokenValidator();
$validator->validate('some.jwt.token', '/path/to/public.key');