Laravel Passport no longer has a routes() method
Call to undefined method Laravel\Passport\Passport::routes()Short answer
Passport 11 stopped needing Passport::routes() because it registers its OAuth routes itself, and the method is gone. Delete the call from your service provider. If you changed the routes before, call Passport::ignoreRoutes() in register() and copy the routes you want into routes/web.php.
Fix it fast
1Find out which cause you have
Find every place the method is called, and see which Passport version is installed.
grep -rn "Passport::routes" app bootstrap routes composer show laravel/passport2Match what you see, then jump to its fix
What does the error look like?
Call to undefined method Laravel\Passport\Passport::routes()
Cause 1 of 2
Old setup code still calls Passport::routes()
1Check
Older tutorials add Passport::routes() to a service provider. The Passport upgrade guide for 11.0 says the call can be removed because the routes now come from a dedicated route file.
grep -rn "Passport::routes" app bootstrap2Fix
Delete the call. Do nothing else for the default /oauth routes.
// remove this line from the provider
// Passport::routes();3Verify
The routes are still registered after the call is gone.
php artisan route:list | grep oauthConfirmed by raw.githubusercontent.com
Cause 2 of 2
The app customised the routes through the old callback
1Check
The upgrade guide says routes you overrode with the old method can be overridden in your own routes file instead.
grep -rn -A4 "Passport::routes(" app2Fix
Tell Passport not to register its routes, then copy the ones you need from its routes file into routes/web.php and edit them.
// app/Providers/AppServiceProvider.php
use Laravel\Passport\Passport;
public function register(): void
{
Passport::ignoreRoutes();
}3Verify
Only your copied routes appear.
php artisan route:list | grep oauthConfirmed by laravel.com
How do I stop it coming back?
- Read the package's upgrade guide before every major version bump.
- Keep setup code in one provider so leftover calls are easy to find.
- Run php artisan route:list in CI to notice missing OAuth routes.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Laravel Passport cannot find a personal access client
createToken fails for a user, and no token is returned
createToken needs a personal access client, and the database you are connected to does not have one.
3 causes, each with a fixBack end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fix