PHP code example of leonis / apikey-auth

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

    

leonis / apikey-auth example snippets


    'providers' => [
        // ...
        Leonis\ApiKeyAuth\Providers\ServiceProvider::class
     ],
     

    $app->register(Leonis\ApiKeyAuth\Providers\ServiceProvider::class);
    

    'guards' => [
            // ...
    
            'api' => [
                'driver' => 'api_key',
                'provider' => 'users',
            ],
        ],
    

    ApiKey::fromUser(User::first());
    ApiKey::fromId($user->id);
    
bash
    php artisan vendor:publish --provider="Leonis\ApiKeyAuth\ApiKeyAuthServiceProvider"
    
bash
    php artisan migrate
    
bash
    php artisan migrate