PHP code example of danilo / passport

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

    

danilo / passport example snippets


    'providers' => [
        ...
        jumpitt\passport\MultiServiceProvider::class,
    ],



namespace App;

use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;

    const PASSPORT = 4;

    protected $fillable = [
        'name', 'email', 'password',
    ];
    ...
}


class Kernel extends HttpKernel
{
    ...
    protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'check-guard' => \App\Http\Middleware\CheckGuard::class,
        'custom-provider' => \App\Http\Middleware\PassportCustomProvider::class,
    ];
    ...
}



use Illuminate\Http\Request;

Route::group(['middleware' => ['check-guard:customer', 'auth:customer']], function(){
    Route::post('details', 'TestController@details');
});
console
$ php artisan make:auth
console
$ php artisan migrate
console
$ php artisan passport:install
console
$ php artisan passport:client --password
console
$ php artisan vendor:publish
console
$ php artisan migrate