routesAreCached() method in Laravel is undefined
P粉304704653
P粉304704653 2023-11-08 18:45:24
0
2
519

Please give me a little help. I'm trying to set up passport for my Laravel application following the official documentation. But I'm stuck on the steps I need to check before callingPassport::routes(). My vscode shows error

Undefined method: routesAreCached()

Even when I trace back to the base abstract class ServiceProvider.php, the code there seems to call$this->app->routesAreCached()without any issues. Below is my AppProvidersAuthServiceProvider.php code.

 */ protected $policies = [ // 'AppModelsModel' => 'AppPoliciesModelPolicy', ]; /** * Register any authentication / authorization services. * * @return void */ public function boot() { $this->registerPolicies(); /** * This method will register the routes necessary to issue access tokens and revoke access tokens, clients, and personal access tokens: * */ if (! $this->app->routesAreCached()) { // error at this line Passport::routes(); } } }


P粉304704653
P粉304704653

reply all (2)
P粉006847750

Try this

/** @var CachesRoutes $app */ $app = $this->app; if (!$app->routesAreCached()) { Passport::routes(); }

I hope it works!

    P粉536909186

    Passport's routes have been moved to a dedicated routes file. You can remove thePassport::routes()call from your application's service provider.This link may be helpful

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!