PHP code example of bayareawebpro / laravel-simple-jwt

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

    

bayareawebpro / laravel-simple-jwt example snippets


JWT_SECRET=XXX

JsonWebToken::register(User::class, 'token');

$token = JsonWebToken::createForUser(User::first(), now()->addHours(3), [
  'my_key' => true
]);

$request->jwt()->get('my_key');
$request->jwt('my_key');

$newToken = JsonWebToken::extendToken(request()->jwt(), now()->addHours(3), ['key' => true]);

$bannedUUID = request()->jwt('jti');

JsonWebToken::rejectionHandler(fn($parsed)=>in_array($parsed->get('jti'),[
    $bannedUUID
]));
text
Authorization: Bearer XXX