在我今天得到的PHP Intelephense的最新更新之后,Intelephense一直显示我的路由(和其他类)的未定义符号的错误,以前没有这样的错误,它困扰着我。

以下是错误截图:

这是我的代码:

Route::group(['prefix' => 'user', 'namespace' => 'Membership', 'name' => 'user.'], function () {
    Route::get('profile', 'ProfileController@show')->name('profile.show');
    Route::patch('profile', 'ProfileController@update')->name('profile.update');
    Route::patch('change-password', 'ChangePasswordController@change')->name('change-password');
    Route::get('role', 'ProfileController@getRole')->name('profile.role');
    Route::get('summary', 'SummaryController@show')->name('summary');
    Route::get('reserved', 'AuctionController@reservedAuction')->name('reserved');
});

实际上,这段代码中没有错误,但intelephense一直显示错误,所以有办法解决这个问题吗?


当前回答

在你的web。php中

添加这行代码

use Illuminate\Support\Facades\Route;

然后你就完成了,如果你得到了认证错误,然后添加这行代码

use Illuminate\Support\Facades\Auth;

谢谢。

其他回答

在我的例子中,由于某种原因,供应商文件夹在VS Code设置中被禁用:

    "intelephense.files.exclude": [
        "**/.git/**",
        "**/.svn/**",
        "**/.hg/**",
        "**/CVS/**",
        "**/.DS_Store/**",
        "**/node_modules/**",
        "**/bower_components/**",
        "**/vendor/**", <-- remove this line!
        "**/resources/views/**"
    ],

通过删除包含供应商文件夹的行,它可以在Intelephense 1.5.4版本上正常工作

你不需要降级,你可以:

在设置中禁用未定义的符号诊断——"intelephense.diagnostics. "undefinedSymbols": false。

或者使用ide助手为laravel外观添加存根。参见https://github.com/barryvdh/laravel-ide-helper

对那些宁愿保持简单的人来说,愚蠢;如果你想摆脱通知,而不是安装帮助程序或降级,只需在设置中禁用错误。Json:

"intelephense.diagnostics.undefinedTypes": false

不,只有在自动更新Intelephense扩展后才会出现错误。

要解决这个问题,您可以通过单击Intelephense扩展中的“安装另一个版本”将其降级到以前的版本。版本1.2.3上没有错误。

1.3.1固定它。

只要更新你的扩展,你应该是好的去