如何在 Eclipse 中为 PHP 核心功能启用自动完成/语法高亮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1293762/
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
How to enable autocomplete/syntax-highlight for PHP core functions in Eclipse?
提问by Edward
I searched a lot, checked many times the neccesary steps, but it still don't work.
我搜索了很多,检查了很多必要的步骤,但它仍然不起作用。
My environment is :
我的环境是:
Latest eclipse for PHP developer package
Project is newed, not check out directly from SVN
.project has a line
<nature>org.eclipse.php.core.PHPNature</nature>.buildpath has a line
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>.settings/org.eclipse.core.resources.prefs has a line
include_path=0;/projectnamefile ensured opened in PHP Editor
PHP 开发包的最新 eclipse
项目是新的,不是直接从SVN签出
.project 有一条线
<nature>org.eclipse.php.core.PHPNature</nature>.buildpath 有一行
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>.settings/org.eclipse.core.resources.prefs 有一行
include_path=0;/projectname确保在 PHP 编辑器中打开的文件
Something works:
一些工作:
- PHP core function defination displayed when mouse over, and Ctrl+Click will open its defined file, but input 'arr' nothing happens, while a list of array functions expected
- Autocomplete does work for internal functios/variables such as class members But never works for PHP core functions, neither syntax highlighting
- 鼠标悬停时显示PHP核心函数定义,Ctrl+单击将打开其定义的文件,但输入'arr'没有任何反应,而预期的数组函数列表
- 自动完成确实适用于内部函数/变量,例如类成员,但不适用于 PHP 核心函数,语法高亮也不适用
回答by Benjamin Cremer
Right-Click on your project -> Configure -> Add PHP Support...
右键单击您的项目 -> 配置 -> 添加 PHP 支持...
Works for me on Eclipse 3.5 / PDT 2.1
在 Eclipse 3.5 / PDT 2.1 上对我有用
回答by tman
For me, nothing worked, except:
对我来说,没有任何效果,除了:
- Backup and then delete the .db files under: /.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2/
- Restart eclipse.
- 备份然后删除下的 .db 文件:/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2/
- 重启日食。
I got this tip from #4 in: http://www.nwiresoftware.com/blogs/nwire/2010/09/five-tips-speeding-eclipse-pdt-and-nwire
我从 #4 中得到了这个提示:http: //www.nwiresoftware.com/blogs/nwire/2010/09/five-tips-speeding-eclipse-pdt-and-nwire
回答by Patrick
As noted before the 'natures' node for php core is listed but this is most insufficient when the project is imported or checked out.
如前所述,列出了 php 核心的 'natures' 节点,但是当项目被导入或检出时,这是最不充分的。
- Make a backup of your .project
- Remove the 'natures' node children
- Close/Re-open eclipse
- Right-click project -> Configure -> Add PHP Support
- Add back other 'natures' children
- 备份您的 .project
- 删除 'natures' 节点子节点
- 关闭/重新打开日食
- 右键项目 -> 配置 -> 添加 PHP 支持
- 添加回其他“自然”的孩子
The issue is that project will not make the necessary imports because it assumes it already has.
问题是项目不会进行必要的导入,因为它假设它已经有了。
回答by Dino Veli?
Nothing helped, but this:
没有任何帮助,但是这个:
In Eclipse:
在日食中:
Go to Window -> Preferences -> General -> Editors -> File Associations
转到窗口 -> 首选项 -> 常规 -> 编辑器 -> 文件关联
Click Add
点击添加
Type *.php
输入 *.php
Under Associated Editors choose PHP Editor and click Default on the right.
在 Associated Editors 下选择 PHP Editor 并单击右侧的 Default。
Close and open your php file.
关闭并打开您的 php 文件。
回答by user3287714
There are 3 .dll files: model.h2.db, model.lock.db and model.trace.db under workspace/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2
在workspace/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2下有3个.dll文件:model.h2.db、model.lock.db和model.trace.db
Remove these files and restart Eclipse.
删除这些文件并重新启动 Eclipse。
回答by yogesh suhagiya
If issue is still exists, follow the following steps:
如果问题仍然存在,请按照以下步骤操作:
Remove project from eclipse.
Goto your project folder and remove .Settings folder and .project file.
Again import php project with different name.
从 Eclipse 中删除项目。
转到您的项目文件夹并删除 .Settings 文件夹和 .project 文件。
再次导入不同名称的 php 项目。
it's work for me.
这对我有用。
回答by ino
Right-Click on your project -> Configure -> Convert to PHP Project...
右键单击您的项目 -> 配置 -> 转换为 PHP 项目...
Works for me on Eclipse 4.6 / PDT 5.2
在 Eclipse 4.6 / PDT 5.2 上对我有用
回答by VonC
There seem to still be a lot of bugs related to auto-completion for the PHP Development Tools Project (PDT)(See Open Bugs).
似乎仍然有很多与PHP 开发工具项目 (PDT) 的自动完成相关的错误(请参阅Open Bugs)。
One has been entered two days ago: bug 286733"When using sub namespace completion does not work."
两天前输入了一个:bug 286733“使用子命名空间完成时不起作用”。


But this is hardly the only one:
但这并不是唯一的:
- "Autocomplete on namespaces failed" (bug 281766)
- "
[php 5.3]Code assist doesn't provide method completion" (bug 286068) - ...
They are all related to the namespace of the PHP code. Could you check if you reproduce the error in a global namespace?
它们都与 PHP 代码的命名空间有关。你能检查一下你是否在全局命名空间中重现了错误吗?

