views:

11909

answers:

15

I have Eclipse 3.3.2 with PDT doing PHP development. All projects that I create, even SVN projects have code completion. Now I just opened another SVN project and it has no code completion or PHP templates (STRG-space does nothing in that project). However, I can open the other projects and code completion all work in them.

Why would code completion and templates be "off" in just one project and how can I turn it back on?

+11  A: 

Maybe Eclipse doesn't understand the project has a "PHP nature". Try comparing the .project file on both projects to look for differences. It should contain something like:

 <natures>
  <nature>org.eclipse.php.core.PHPNature</nature>
 </natures>
Guido
Because the repository had a .project file in it, it did not give me the chance to open it with the PHP project wizard, we deleted the .project file, rechecked it out and all is fine now, thanks!
Edward Tanguay
A: 

Be sure the file opens with the "PHP editor". Right-click the file, and select open with to select the right editor.

If it turns out you've been using the wrong editor, you can change the association under Preferences » General » Content Types

Sietse
+1  A: 

I have the same issue sometimes. For me it works to rebuild the PHP project with "Project" -> "Clean".

Joe Scylla
A: 

One solution could be to include a dummy php file wich requires all your PHP classes. So that the PHP parser recognizes these classes too. Example dummy file:

if(false) {
     require_once 'class/one.php';
     require_once 'class/two.php';
     require_once 'class/three.php';
}
powtac
A: 

I've noticed sometimes when you checkout a project from svn in eclipse (subversive or subsclipe "checkout a project as") and even though you check it out as a php project it will either delete the .project file or it would be a generic project. I've found to just go in that directory and delete the .project .settings/ and .cach/

Then create a new php project and point the directory where you checked out the files. And you should have code completion and svn should be link to your repo.

Brendon
+5  A: 

Thank you! I spent all day long to figure out why I did not have code completion...

The problem is that if you create a SVN project the .project is a basic file without codecompletion reference. You have to create a basic PHP project and compare the two files and replacing the missing part in the SVN project one.

Now I have code completion for every file in the project, even for Zend Framework library

A: 

I had a problem that build path was empty, so no code completion for any of the files i tried to edit. Make sure you setup properly your build path, especially if you're linking the source from some other location than the workspace.

Like the apache htdocs folder for example.

vanja
+1  A: 

Right click in the edit screen, goto Java -> Editor -> Content Assist -> Advanced ...select proposals accordingly

ddd
A: 

Look out for the file .buildpath in your project... put this line between the tag:

<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>

Save it and restart eclipse. Now everything should be OK... This worked for me. :)

A: 

I have solved this by enabling the Full C/C++ indexer (Windows-> properties -> C/C++ -> Indexer), and also hit the radio button "Use active button configuration". After that Clean, and Build all.

That worked on Eclipse CDT 3.4

Andre
+3  A: 

It is just one line to add in the .project file and then restarting eclipse to get codecompletion: Where it says

---
 <natures>
 </natures>
---

after the change has to be

---
 <natures>
  <nature>org.eclipse.php.core.PHPNature</nature>
 </natures>
---

That should do.

lagopixel
A: 

If you came here looking for code completion in php eclipse not working, make sure your project is being supported as a php project. Right click on the project and then go to configure -> Add php support. If you have the right settings for code assist it should work instantaneously. Sometimes newbies as me tweak around with the projects or start projects as clean and not as php so eclipse doesn't know how to treat the project.

Camilo
A: 

ATTENTION

Besides the already mentioned solutions to get the whole autocomplete help to work, there is another quirk: it might not be enabled.

Go to Window > Properties and then to PHP > Editor > Code Assist (JAVA has a similar option) and set "Enable auto activation", preferably with a delay that you see comfortable (0ms). If you are bothered by the program suddenly deciding to do things for you without prompt (and doing it wrong), deselect "Insert single proposals automatically" and you should be fine.

John