Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I tried to use Laravel-passport so I installed this package in my project, but when i wanted to make route i wrote this code in the AuthServiceProvider

 public function boot()
    {
        $this->registerPolicies();
   
        Passport::routes();
 
    }

When i run php artisan route:list in the cmd i face with this error

  • Call to undefined method Laravel\Passport\Passport::routes()
like image 687
Mahdi khadimi Avatar asked Feb 02 '26 23:02

Mahdi khadimi


2 Answers

Since version 11 passport's routes have been moved to a dedicated route file. You can remove the Passport::routes() call from your application's service provider.

If you dont want to use default passport routes. you can disabled the route in register method inside AppServicerProvider

public function register()
{
   Passport::ignoreRoutes();
}

and you can copy the default passport routes from vendor laravel\passport\routes\web.php

for more detail about UPGRADE read this https://github.com/laravel/passport/blob/11.x/UPGRADE.md

like image 190
Aslam H Avatar answered Feb 05 '26 13:02

Aslam H


Remove this comment on this line on your AuthServiceProvider file.

protected $policies = [
        'App\Models\Model' => 'App\Policies\ModelPolicy',
    ];
like image 41
Switi Avatar answered Feb 05 '26 13:02

Switi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!