在我今天得到的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一直显示错误,所以有办法解决这个问题吗?


当前回答

我也有同样的问题,下面的内容似乎已经解决了这个问题。

a)更新至最新版本1.3.5,并重新启用所有诊断设置。

我还在接收信息

b)将带有依赖库的vendor文件夹添加到工作区

这似乎解决了问题。

其他回答

use Illuminate\Support\Facades\Route;

警告导入相应的命名空间后消失。

版本的

幼虫 6+ VSCODE 版本 1.40.2 PHP Intelephense 1.3.1

这实际上是一组用于编辑器理解Laravel的配置。

如果您想手动配置它,这里是repo。这是为vscode和PhpStorm。

或者如果你愿意,你可以下载这个包。(我创建的)建议全局安装。

然后运行andylaravel setupIDE。这将根据第一个repo为您配置所有内容。

自版本1.7.1以来,有其他解决方案

现在你可以知道intelephense应该在哪里寻找依赖项,例如vendor是最常见的。

"intelephense.environment.includePaths": [
    "vendor"
],

此外,它甚至绕过了VSCode规则

"files.exclude": {
    "**/vendor": true
},

你可以在这里阅读更多的更新日志

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

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

版本1.3.0有缺陷。 降级到1.2.3版本可以解决我的问题。 我在

Laravel 5.1 PHP 5.6.40