PHP code example of kuma-guy / jwt-auth-module

1. Go to this page and download the library: Download kuma-guy/jwt-auth-module 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/ */

    

kuma-guy / jwt-auth-module example snippets


use Ray\Di\AbstractModule;
use BEAR\JwtAuth\Auth\Auth;
use BEAR\JwtAuth\SymmetricJwtAuthModule;

class AppModule extends AbstractModule
{
    protected function configure()
    {
        $this->install(new SymmetricJwtAuthModule('symmetric algorithm', 'token time-to-live', 'secret'));
        $this->bind(Auth::class)->toProvider(AuthProvider::class)->in(Scope::SINGLETON);
    }
}

use Ray\Di\AbstractModule;
use BEAR\JwtAuth\Auth\Auth;
use BEAR\JwtAuth\AsymmetricJwtAuthModule;

class AppModule extends AbstractModule
{
    protected function configure()
    {
        $this->install(new AsymmetricJwtAuthModule('asymmetric algorithm', 'token time-to-live', 'private key', 'public key', 'pass phrase'));
        $this->bind(Auth::class)->toProvider(AuthProvider::class)->in(Scope::SINGLETON);
    }
}