Home > Software engineering >  Undefined type 'App\Providers\Passport' laravel 8
Undefined type 'App\Providers\Passport' laravel 8

Time:11-07

I've follow the installation instruction to Install passport from the laravel official documentation and the installation completed successfully, but when I try to add passport routes method within the boot method of my App\Providers\AuthServiceProvider its give me this error Undefined type 'App\Providers\Passport'

here is my composer.json

{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
    "php": "^7.3|^8.0",
    "fruitcake/laravel-cors": "^2.0",
    "guzzlehttp/guzzle": "^7.4",
    "laravel/framework": "^8.65",
    "laravel/passport": "^10.2",
    "laravel/sanctum": "^2.11",
    "laravel/tinker": "^2.5",
    "symfony/psr-http-message-bridge": "^2.1"
},
"require-dev": {
    "facade/ignition": "^2.5",
    "fakerphp/faker": "^1.9.1",
    "laravel/sail": "^1.0.1",
    "mockery/mockery": "^1.4.4",
    "nunomaduro/collision": "^5.10",
    "phpunit/phpunit": "^9.5.10"
},
"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Database\\Factories\\": "database/factories/",
        "Database\\Seeders\\": "database/seeders/"
    }
},
"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},
"scripts": {
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover --ansi"
    ],
    "post-update-cmd": [
        "@php artisan vendor:publish --tag=laravel-assets --ansi"
    ],
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate --ansi"
    ]
},
"extra": {
    "laravel": {
        "dont-discover": []
    }
},
"config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}

here is my AuthServiceProvider.php

  <?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
{
    
    protected $policies = [
        // 'App\Models\Model' => 'App\Policies\ModelPolicy',
    ];

public function boot()
{
    $this->registerPolicies();

    Passport::routes();
    

    }
}

I don't know what is the problem

CodePudding user response:

=>remove the comment then run.
protected $policies = [
        'App\Models\Model' => 'App\Policies\ModelPolicy',
    ];
  • Related