请帮我一点忙。我正在尝试按照官方文档为我的 Laravel 应用程序设置护照。但我陷入了在调用 Passport::routes()
之前需要检查的步骤。我的 vscode 显示错误
未定义的方法:routesAreCached()
即使当我追溯到基本抽象类ServiceProvider.php时,那里的代码似乎调用 $this->app->routesAreCached()
没有任何问题。下面是我的 AppProvidersAuthServiceProvider.php 代码。
<?php namespace AppProviders; use IlluminateFoundationSupportProvidersAuthServiceProvider as ServiceProvider; use IlluminateSupportFacadesGate; use LaravelPassportPassport; class AuthServiceProvider extends ServiceProvider { /** * The model to policy mappings for the application. * * @var array<class-string, class-string> */ 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粉0068477502023-11-09 14:07:52
试试这个
/** @var CachesRoutes $app */ $app = $this->app; if (!$app->routesAreCached()) { Passport::routes(); }
我希望它有用!
P粉5369091862023-11-09 12:22:10
Passport 的路线已移至专用路线文件中。您可以从应用程序的服务提供商处删除 Passport::routes()
调用。
此链接可能有帮助