PhpStorm 和 Laravel 自动补全

编程入门 行业动态 更新时间:2024-10-27 20:37:14
本文介绍了PhpStorm 和 Laravel 自动补全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我决定在我的新 Laravel 项目中使用 PhpStorm,所以我想我想要一些自动完成功能.我确实阅读了 blog.jetbrains 的指南/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 blog.jetbrains/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 上找到关于这个包的更多帮助:github/barryvdh/laravel-ide-helper

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

更多推荐

PhpStorm 和 Laravel 自动补全

本文发布于:2023-06-02 08:36:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/440285.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PhpStorm   Laravel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!