0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Error : Call to undefined method Laravel\Passport\Passport::routes()

Last updated at Posted at 2023-11-23

The error happened when I was trying to use Laravel passport. I created Laravel project and installed Laravel Passport, and wrote this code for making route.

App\Providers\AuthServiceProvider.php
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Laravel\Passport\Passport;

class AuthServiceProvider extends ServiceProvider
{
・・・
    public function boot()
    {
        $this->registerPolicies();

        // wrote this
        if (! $this->app->routesAreCached()) {
            Passport::routes();
        }
    }
・・・
}

Then when I run this command,

$ php artisan make:controller AuthController

I got this error.

Call to undefined method Laravel\Passport\Passport::routes()

How to resolve

I found this question in this website and there is a correct answer.

The answer stated that since version 11, passport's routes have been moved to a dedicated route file, so I just removed this Passport::routes(), it was resolved.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?