PHP code example of php-cpm / http-basic-auth-guard

1. Go to this page and download the library: Download php-cpm/http-basic-auth-guard 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/ */

    

php-cpm / http-basic-auth-guard example snippets


$app->register(Phpcpm\BasicAuth\BasicGuardServiceProvider::class);

// config/auth.php
'guards' => [
    'api' => [
        'driver' => 'basic',
        'provider' => 'users'
    ],

    // ...
],

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model'  => App\User::class,
    ],
],

Route::get('api/whatever', ['middleware' => 'auth:api', 'uses' => 'NiceController@awesome']);



namespace App\Http\Controllers;

class NiceController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth:api');
    }
}
bash
$ composer