0

I am receiving an error when trying to execute $ php artisan passport:install on my terminal, which I will paste below:

In AuthServiceProvider.php line 26:
                                            
  Class 'App\Providers\Passport' not found  

I suspect the issue is in my config/auth.php , so I will link the contents below (comments removed):

<?php

return [

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

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

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

    ],

    'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
    ],

];

Below are other files where I have referred to Laravel Passport...

App/user.php :

<?php
    namespace App;
    
    use Laravel\Passport\HasApiTokens;
    use Illuminate\Notifications\Notifiable;
    use Illuminate\Foundation\Auth\User as Authenticatable;
    
    class User extends Authenticatable
    {
        use HasApiTokens, Notifiable;
        
        protected $fillable = ['name', 'email', 'password', 'chatkit_id'];
        
        protected $hidden = ['password', 'remember_token'];
        
        public function setPasswordAttribute($value)
        {
            $this->attributes['password'] = bcrypt($value);
        }
        }

app/providers/AuthServiceProvider.php :

<?php

namespace App\Providers;

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

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

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

        //
    }
}

any ideas on how to resolve this problem?

2 Answers 2

3

It seem you need add Passport:

use Laravel\Passport\Passport;
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, adding that to the top of my app/providers/authserviceprovider.php worked! thanks!
2

you need call to class. "AuthServiceProvider.php" add to file top;

use Laravel\Passport\Passport;

or

use App\Providers\Passport;

1 Comment

thoughtfulness. I fixed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.