PHP code example of d076 / sanctum-refresh-tokens

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

    

d076 / sanctum-refresh-tokens example snippets

 artisan vendor:publish --tag=sanctum-refresh-tokens
 artisan migrate

    use D076\SanctumRefreshTokens\Models\AuthenticatableUser;
    
    class User extends AuthenticatableUser
    {
    }
    

    use Illuminate\Support\Facades\Schedule;
    
    Schedule::command('sanctum:prune-expired --hours=0')->hourly();
    Schedule::command('sanctum:prune-refresh-expired --hours=0')->daily();
    

    use D076\SanctumRefreshTokens\Services\TokenService;
    
    /** @var \D076\SanctumRefreshTokens\Models\AuthenticatableUser $user */
    (new TokenService($user))->createTokens();
    (new TokenService($user))->deleteCurrentTokens();
    

    'expiration' => env('SANCTUM_ACCESS_TOKEN_EXPIRATION', 60), // minutes
    'refresh_token_expiration' => env('SANCTUM_REFRESH_TOKEN_EXPIRATION', 43200), // minutes
    'refresh_token_expiration_no_remember' => env('SANCTUM_REFRESH_TOKEN_EXPIRATION_NO_REMEMBER', 1440), // minutes