PHP code example of amreljako / secure-sanctum

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

    

amreljako / secure-sanctum example snippets


return [
    'token_expiry_days' => 30,
    'allow_multiple_devices' => true,
    'refresh_token_enabled' => true,
    'max_devices_per_user' => 3,
];

use Amreljako\SecureSanctum\Services\TokenManager;

$token = app(TokenManager::class)->createToken($user, 'MyDevice', ['*'], 7);

$record = app(TokenManager::class)->validateToken($plainToken);
bash
php artisan vendor:publish --tag=secure-sanctum-config
bash
php artisan migrate
json
{
  "access_token": "plain-text-token",
  "expires_in_days": 30
}