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.