PhpStorm 和 Laravel 自动补全 [英] PhpStorm and Laravel autocompletion

查看:66
本文介绍了PhpStorm 和 Laravel 自动补全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定在我的新 Laravel 项目中使用 PhpStorm,所以我想我想要一些自动完成功能.我确实阅读了 https://blog.jetbrains 的指南.com/phpstorm/2015/01/laravel-development-using-phpstorm/,其中一些工作正常,但我遇到了问题.

I decided to use PhpStorm for my new Laravel project, so I thought I wanted some autocompletion. I did read the guide from https://blog.jetbrains.com/phpstorm/2015/01/laravel-development-using-phpstorm/ and some of it works fine, but I got a problem.

我想测试我的数据库连接,所以我做了一个简单的index()函数

I wanted to test my DB connection, so I just made a simple index() function like this

if(DB::connection()->getDatabaseName()) {
    echo 'Connected to ' . DB::connection()->getDatabaseName();
}

哪个工作正常,但是当我写 DB 并按 Tab 时,我写的是 \DB:: 而不是 DB::.然后我包括 use Illuminate\Support\Facades\DB;DB:: 作品.但是当我添加门面时,自动完成完全不一样,它找不到方法但它们有效.真的很烦.

Which works fine, but when I write DB and press Tab I write \DB:: instead of DB::. Then I include use Illuminate\Support\Facades\DB; and DB:: works. But when I added the facade, the autocompletion isn't the same at all and it cant find the methods but they works. It's really annoying.

其他人遇到了这个问题,有解决方案吗?

Someone else had this problem and is there a solution for it?

推荐答案

在 PhpStorm 中,设置 => 插件

In PhpStorm, Settings => plugins

  • 搜索 laravel 的存储库并安装.

然后在添加这个包之后:

Then after add this package:

composer 需要 barryvdh/laravel-ide-helper

你可以在 github 上找到关于这个包的更多帮助:https://github.com/barryvdh/laravel-ide-helper

You can find more help on github for this package:https://github.com/barryvdh/laravel-ide-helper

这篇关于PhpStorm 和 Laravel 自动补全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆