Eclipse 自动完成功能不适用于 PHP 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8574962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse autocomplete is not working for PHP-project
提问by Michiel
My Eclipse doesn't use auto-complete... My colleague get a whole list of suggestions by just typing some letters and I get nothing...
我的 Eclipse 不使用自动完成功能......我的同事只需输入一些字母就可以获得完整的建议列表,但我什么也没得到......
The Eclipse version I use is:
我使用的 Eclipse 版本是:
Eclipse for PHP Developers
Version: Helios Service Release 2
Build id: 20110301-1815
(c) Copyright Eclipse contributors and others 2000, 2011. All rights reserved.
Visit http://eclipse.org/
And I think I've set all available settings for autocomplete.
I lose a huge amount of time every time I have to search for the correct naming. Is there any module of software I've to install extra to get this autocompletion?
我想我已经为自动完成设置了所有可用的设置。
每次必须搜索正确的命名时,我都会浪费大量时间。是否有任何软件模块我必须额外安装才能获得此自动完成功能?
回答by Michiel
Ok, found the solution! Apparently I had to "Add PHP support" in the properties window of the project. Thanks for all the help though!
好的,找到解决方案!显然我必须在项目的属性窗口中“添加 PHP 支持”。谢谢大家的帮助!
回答by nfrozi
I did it by deleting ".metadata" directory on my main workspace :D
我通过删除主工作区上的“.metadata”目录来做到这一点:D
回答by Shiplu Mokaddim
Generally this can be activated by enabling Content Assist. It can be found on Window-Preference->PHP->Editor->Content Assist
通常,这可以通过启用Content Assist来激活。它可以在Window-Preference->PHP->Editor->Content Assist 上找到
- Setup your
php_include_path
. Go to the propertiesof the project. Then PHP Include Path. - If you have any external libraryadd it there too (I use Zendand Kohana).
- 设置您的
php_include_path
. 转到项目的属性。然后PHP 包含路径。 - 如果你有任何外部库也添加它(我使用Zend和Kohana)。
回答by Claudiojd
I can try ALL answers (from this and others threads), only work for me delete (or rename for backup) .metadata
folder on workspace folder
我可以尝试所有答案(来自这个和其他线程),只对我有用,删除(或重命名备份).metadata
工作区文件夹上的文件夹
- Close eclipse
mv .metadata .metadata_older
- Start eclipse (clean start wrokspace of eclipse, none project are listed)
- Import from workspace your project
- Eclipse rebuild and refresh works (several project settings are lost!!!)
- Autocompletion, follow code, etc now work.
- 关闭日食
mv .metadata .metadata_older
- 启动eclipse(清理eclipse的start wrokspace,没有列出任何项目)
- 从工作区导入您的项目
- Eclipse 重建和刷新工作(几个项目设置丢失!!!)
- 自动完成、跟随代码等现在可以工作了。
This isn't the ideal solution, but is the ONLY solution for me, I migrated from eclipse 3.6 to 4.4 in one step, and PHP support is gone, only highlight code are working until delete .metadata
folder.
这不是理想的解决方案,但对我来说是唯一的解决方案,我一步从 eclipse 3.6 迁移到 4.4,并且 PHP 支持消失了,只有突出显示代码才能工作,直到删除.metadata
文件夹。
Ubuntu 12.04 LTS 64 Java 1.7 ORACLE
Ubuntu 12.04 LTS 64 Java 1.7 ORACLE
Thanks.
谢谢。
回答by Sunil Bannur
Check the options in Windows preferences for content assist. It might be disabled. It probably would be php -> Editor -> Content Assist and see what is selected for auto activation.
检查 Windows 首选项中的选项以获取内容帮助。它可能被禁用。它可能是 php -> Editor -> Content Assist 并查看为自动激活选择了什么。
回答by fin1te
I don't use Eclipse, but I know in Netbeans (and other IDE's) you can type Ctrl+ Spaceto bring up the auto complete window after you start typing a function/variable.
我不使用 Eclipse,但我知道在 Netbeans(和其他 IDE)中,您可以在开始键入函数/变量后键入Ctrl+Space以显示自动完成窗口。
Give that a try.
试一试吧。
回答by Radek Pech
If this happens only for one project in Eclipse and others are autocompleting correctly, it sometimes happen when you create new PHP project and press Finish
on the first page.
如果这仅发生在 Eclipse 中的一个项目上,而其他项目正在正确自动完成,则有时会在您创建新的 PHP 项目并按下Finish
第一页时发生。
To fix it, remove the project from Eclipse (Windows > Show view > Navigator
and press DELETE
on the project). Then go to project folder and delete file .project
and folder .setting
.
要修复它,请从 Eclipse 中删除该项目(Windows > Show view > Navigator
并按下DELETE
该项目)。然后转到项目文件夹并删除文件.project
和文件夹.setting
。
In Eclipse now select File > New > PHP project
, select name and folder, press Next
and verify (or manually add) that root folder of the project is listen on Source
tab.
现在在 Eclipse 中选择File > New > PHP project
,选择名称和文件夹,按下Next
并验证(或手动添加)项目的根文件夹在Source
选项卡上监听。
Then click Next
and add root folder of the project or folders that contain PHP files into Build path
. Now you can click Finish
.
然后单击Next
将项目的根文件夹或包含 PHP 文件的文件夹添加到Build path
. 现在您可以单击Finish
。
Note: adding Source
and Build
paths into existing project usually does not fix this problem and you really have to delete and create new project.
注意:在现有项目中添加Source
和Build
路径通常不能解决此问题,您确实必须删除并创建新项目。
回答by ido niger
Right click on the project -> Properties -> PHP -> Validation
右键单击项目 -> 属性 -> PHP -> 验证
Check the Enable prockect specific settings
检查启用 procect 特定设置
Select PHP Ver
选择 PHP 版本
回答by Rodrigo Guariento
Check your .buildpath, try build something like this:
检查您的.buildpath,尝试构建如下内容:
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
<buildpathentry kind="src" path="src"/>
<buildpathentry kind="src" path="vendor"/>
<buildpathentry external="true" kind="lib" path="common-libs/vendor/project-sample/lib"/>
</buildpath>