How to enable autocomplete/syntax-highlight for PHP core functions in Eclipse?
Asked Answered
L

8

28

I searched a lot, checked many times the neccesary steps, but it still don't work.

My environment is :

  1. Latest eclipse for PHP developer package

  2. Project is newed, not check out directly from SVN

  3. .project has a line

    <nature>org.eclipse.php.core.PHPNature</nature>
    
  4. .buildpath has a line

    <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
    
  5. .settings/org.eclipse.core.resources.prefs has a line

    include_path=0;/projectname
    
  6. file ensured opened in PHP Editor

Something works:

  1. 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
  2. Autocomplete does work for internal functios/variables such as class members But never works for PHP core functions, neither syntax highlighting
Loar answered 18/8, 2009 at 13:17 Comment(0)
G
30

Right-Click on your project -> Configure -> Add PHP Support...

Works for me on Eclipse 3.5 / PDT 2.1

Gypsum answered 19/8, 2009 at 7:23 Comment(6)
ever checked this option, it's grayLoar
wow thanks, this worked for me on Galileo, it's a pain to work without autocomplete for core featuresLisp
I don't see a 'configure' option when I right-click my project in HeliosErik
Don't forget to add <?php ?> tags too!Nye
After you install support for PHP, restarting wasn't enough for me - I had to close any already open files in the editor and then restart and re-open them for the syntax highlighting to work (Eclipse Luna)Laurence
Oxygen (Release 4.7.0) doesn't have "add PHP Support" option in the context menu. In my case, editing the .buildpath file worked.Mensurable
W
22

For me, nothing worked, except:

  1. Backup and then delete the .db files under: /.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2/
  2. Restart eclipse.

I got this tip from #4 in: http://www.nwiresoftware.com/blogs/nwire/2010/09/five-tips-speeding-eclipse-pdt-and-nwire

Witha answered 27/11, 2011 at 9:15 Comment(3)
Worked great, just by deleting the .db files and restarting. ThanksMroz
Worked for Eclipse 4.3 when the add PHP support option was disabled.Treasure
Excellent advice. Does anybody know how and where one would trigger such an reindexing of DLTK within Eclipse? Helped me big time with Eclipse Kepler and PDT 3.2.0! thxDisabled
K
15

As noted before the 'natures' node for php core is listed but this is most insufficient when the project is imported or checked out.

  • 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

The issue is that project will not make the necessary imports because it assumes it already has.

Kavanaugh answered 28/4, 2011 at 19:25 Comment(1)
Right-click project -> Configure -> Add PHP Support is always grayed out for me?Barney
G
2

Nothing helped, but this:

In Eclipse:

Go to Window -> Preferences -> General -> Editors -> File Associations

Click Add

Type *.php

Under Associated Editors choose PHP Editor and click Default on the right.

Close and open your php file.

Geilich answered 23/11, 2015 at 8:42 Comment(0)
P
1

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

Remove these files and restart Eclipse.

Plague answered 24/2, 2014 at 19:30 Comment(0)
C
0

There seem to still be a lot of bugs related to auto-completion for the PHP Development Tools Project (PDT) (See Open Bugs).

One has been entered two days ago: bug 286733 "When using sub namespace completion does not work."

alt text

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?

Crudden answered 18/8, 2009 at 16:18 Comment(1)
not this one, in my project (no namespace specified), also tried a clean PHP project, autocomplete does work for class members, just no effect when input core functions.Loar
J
0

If issue is still exists, follow the following steps:

  1. Remove project from eclipse.

  2. Goto your project folder and remove .Settings folder and .project file.

  3. Again import php project with different name.

it's work for me.

Jariah answered 29/8, 2014 at 5:45 Comment(0)
V
0

Right-Click on your project -> Configure -> Convert to PHP Project...

Works for me on Eclipse 4.6 / PDT 5.2

Venable answered 8/3, 2018 at 6:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.