PHP code example of hungdx / auth-token

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

    

hungdx / auth-token example snippets


HungDX\AuthToken\AuthTokenProvider::class,

$app->register(HungDX\AuthToken\AuthTokenProvider::class);

$app->configure('auth-token');

    'guards' => [
        'web' => [
            'driver'   => 'auth-token',
            'provider' => 'users',
        ],

        'api' => [
            'driver'   => 'auth-token',
            'provider' => 'users',
        ],
    ],

return [
    'lifetime' => [
        'expired' => 7 * 24 * 3600,  // Lifetime of token before expired. Default 7 days
        'refresh' => 3600,           // The minimum seconds before changing the token. Default 1 hour
    ],

    'token_field' => [
        'header' => 'Authorization', // Set [false/null/empty] to disable send token to response header  
        'cookie' => 'X-Auth-Token',  // Set [false/null/empty] to disable send token to response cookie
    ],

    'autoload_middleware' => true,  // Auto add to middleware HungDX\AuthToken\AuthTokenMiddleware to every request
];
shell
php artisan migrate --path="vendor/hungdx/auth-token/migrations"
shell
php artisan migrate --path="vendor/hungdx/auth-token/migrations"
shell
php artisan vendor:publish --provider="HungDX\AuthToken\AuthTokenProvider"