搜尋
問答 Laravel中的routesAreCached()方法未定義
Laravel中的routesAreCached()方法未定義
P粉304704653 2023-11-08 18:45:24 查看 868
PHP

0

請幫我一點忙。我正在嘗試按照官方文件為我的 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();
         }

    }
}


#
Your Answer
提交

2 個答案
0

試試這個

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

我希望它有用!

2023-11-09 14:07:52

提交

0

Passport 的路線已移至專用路線檔案中。您可以從應用程式的服務提供者移除 Passport::routes() 呼叫。 此連結可能有幫助

2023-11-09 12:22:10

提交

Hot Tools

vc9-vc14(32+64位元)運行庫合集(連結在下方)

vc9-vc14(32+64位元)運行庫合集(連結在下方)

phpStudy安裝所需運行函式庫集合下載

VC9 32位

VC9 32位

VC9 32位元 phpstudy整合安裝環境運行庫

php程式設計師工具箱完整版

php程式設計師工具箱完整版

程式設計師工具箱 v1.0 php整合環境

VC11 32位

VC11 32位

VC11 32位元 phpstudy整合安裝環境運行庫

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用