PHP code example of cesg / jwt-token-guard

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

    

cesg / jwt-token-guard example snippets


'api' => [
    'driver' => 'jwt',
    'provider' => 'users',
    'key' => env('JWT_KEY', \md5(env('APP_NAME'))),
],

protected function authenticated(Request $request, $user)
{
    $jwt = JWT::encode([
        'sub' => $user->getAuthIdentifier(),
        'iss' => config('app.name'),
        'iat' => now()->timestamp,
    ], config('auth.guards.api.key'));

    session(\compact('jwt'));
}