英文:
VSCode Intelliphense not working properly with Laravel Projects
问题
在VSCode中,PHP intelephense扩展版本1.3.7将laravel Facades标记为未找到的类。
以前,如果您像这样导入Facade:
use Log;
然后在文件中像这样使用它:
Log::info('一些消息');
这是正确的,没有问题。现在每个使用都被标记为语法错误,您必须导入完全限定的名称,如以下方式才能消除错误。
use \Illuminate\Support\Facades\Log;
另外,它以前不会抱怨Eloquent类的方法,比如find
或where
等,但现在它将它们标记为未定义的方法。
扩展是否有办法忽略这些?
英文:
In VSCode the PHP intelephense extension version 1.3.7 marks the laravel Facades as classes not found.
Before if you import a Facade like this:
use Log;
and then use it in the file like this:
Log::info('some message');
which is correct there were no issues. Now every usage is marked as a syntax error and you have to import the fully qualified name like the following for the error to go away.
use \Illuminate\Support\Facades\Log;
Also it didn't used to complain about the Eloquent class's methods like find
or where
etc but now it underlines them as methods not defined.
Is there a way for the extension to ignore these?
答案1
得分: 1
你可以尝试使用 barryvdh/laravel-ide-helper
。
它使得VScode能够引用Facade文件。
示例)
"require-dev": {
...
"barryvdh/laravel-ide-helper": "^2.7",
...
},
英文:
You can try barryvdh/laravel-ide-helper
.
it makes VScode to refer Facade files.
example)
"require-dev": {
...
"barryvdh/laravel-ide-helper": "^2.7",
...
},
答案2
得分: 0
这里真正拯救生命的解决方案是 php命名空间解析器
扩展,它为您提供了一个下拉菜单,其中包含您想要的所有可能选项。
这是链接
英文:
A solution which is really a life saver here is the php namespace resolver
extension, it gives you all the possible options that you want as a dropdown menu.
Here is the link
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论