Answers for "laravel passport install step by step"

PHP
8

install laravel passport

1 - composer require laravel/passport
2 - php artisan migrate
3 - php artisan passport:install
4 - go to user model
  <?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;
}
?>  
  
5 - go to App\Providers\AuthServiceProvider
  <?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Laravel\Passport\Passport;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Models\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        if (! $this->app->routesAreCached()) {
            Passport::routes();
        }
    }
}  
  ?>
 
7 - go to config/auth.php
    'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],
Posted by: Guest on June-18-2021
7

laravel passport

php artisan passport:install
Posted by: Guest on June-06-2020
1

laravel passport client

for get client key in laravel passport run this command : 
php artisan passport:client --personal
Posted by: Guest on August-09-2021

Code answers related to "laravel passport install step by step"

Browse Popular Code Answers by Language