1

config/app.php

'aliases' => [
    'Route' => Illuminate\Support\Facades\Route::class,
],

当我使用Routeroutes/web.php

Route::get('/', 'UserController@home');

我在我的vs 代码中安装了php intelephense扩展。所以它显示错误

在此处输入图像描述

有谁知道如何解决这个问题?(功能工作正常,但显示错误是问题所在)

4

1 回答 1

1

别名是在运行时注册的,因此它们不在命名空间中,Intelephense 无法获取它们。

请参阅 Github 中 Intelephense 项目的问题https://github.com/bmewburn/vscode-intelephense/issues/1116

“这些类在工作区中不存在。Laravel 在运行时创建它们。因此它们被报告为未定义。解决方案是提供存根定义https://github.com/barryvdh/laravel-ide-helper或转关闭诊断 (intelephense.diagnostics.undefinedTypes)。”

于 2021-02-26T05:34:09.467 回答