PHP code example of dmstr / yii2-token-manager

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

    

dmstr / yii2-token-manager example snippets


use dmstr\tokenManager\components\TokenManager;

return [
    'components' => [
        'tokenManager' => [
            'class' => TokenManager::class
        ]
    ]
];

use dmstr\tokenManager\exceptions\LoadTokenException;

$token = ...; // valid Jwt token

Yii::$app->tokenManager->setToken($token);

try {
    $roles = Yii::$app->tokenManager->getRoles();
} catch (LoadTokenException $exception) {
 // ...
}