PHP code example of ackosoft / auth-adapter

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

    

ackosoft / auth-adapter example snippets



return [
    'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],

    'guards' => [
        'api' => [
            'driver' => 'passport',
            'provider' => 'users'
        ],
    ],

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => \App\User::class
        ]
    ],
    'auth_connection'=>env('AUTH_DB_CONNECTION','mysql')
];


AUTH_DB_CONNECTION=mysql2

// Enable Facades
$app->withFacades();

// Enable Eloquent
$app->withEloquent();

$app->register(Laravel\Passport\PassportServiceProvider::class);
$app->register(\Ackosoft\AuthAdapter\AppServiceProvider::class);
$app->routeMiddleware([
     'auth' => \Ackosoft\AuthAdapter\Middleware\AuthMiddleware::class,
 ]);

$app->configure('auth'); //Add this line if not working properly

class User extends Model implements AuthenticatableContract, AuthorizableContract
{
    use HasApiTokens, Authenticatable, Authorizable;

    /* rest of the model */
}
 

    protected $connection = 'mysql2';