laravel中的routesarecached()方法未定义
请帮我一点。我正在尝试通过遵循官方文档) 。但是,我陷入了需要在调用Passport :: Routes()
之前需要检查的步骤。我的vscode显示了一个错误
未定义的方法:routesarecached()
即使我追溯到基本的Abstract类ServiceProvider.php,那里的代码似乎正在调用$ this-> app-&gt-&gt-; doutesArecached()
毫无问题。以下是我的app \ provers \ authserviceprovider.php代码。
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Laravel\Passport\Passport;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/**
* 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();
}
}
}
Please help me out a bit. I'm trying to setup passport for my Laravel app by following the official docs. But i'm stuck at the step where I need to check before calling Passport::routes()
. My vscode displayed an error saying
undefined method: routesAreCached()
even though when I traced back to the base abstract class ServiceProvider.php, the code there seems to be calling $this->app->routesAreCached()
without any problems. Below is my App\Providers\AuthServiceProvider.php code.
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Laravel\Passport\Passport;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/**
* 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();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
护照的路线已移至专用路线文件。您可以从应用程序的服务提供商中删除
Passport :: Routes()
调用。此链接可能会有所帮助
Passport's routes have been moved to a dedicated route file. You can remove the
Passport::routes()
call from your application's service provider.This link may help
尝试这个
我希望它有用!
Try this
i hope it was useful !
使用这个,它将起作用
Use this , It will work