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


当前回答

我最近解决了自己的问题。通过文件>首选项 我在寻找智慧 有文件的部分被排除了,我注意到供应商文件夹被添加了。 我把它删除了,现在我所有的laravel文件都有索引了

其他回答

use Illuminate\Support\Facades\Route;

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

版本的

幼虫 6+ VSCODE 版本 1.40.2 PHP Intelephense 1.3.1

在我的例子中,由于某种原因,供应商文件夹在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版本上正常工作

1.3.1固定它。

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

在你的web。php中

添加这行代码

use Illuminate\Support\Facades\Route;

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

use Illuminate\Support\Facades\Auth;

谢谢。

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

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

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

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