Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetBeans PHP code completion for own code

Recently I started using NetBeans 6.7 beta for PHP development instead of Textmate and MacGDBp. I am rather amazed with it's feature set and most everything worked out of the box, or was easily configured to my liking.

I am having an issue with the code completion features though; they work for built-in functions, SPL and some of my code, but not all of my code, specifically, it never works for any methods in my classes, regardless of PHPDoc comments.

I can't seem to find any decent questions, let alone answers about this specific subject anywhere. It looks like everybody else who has problems with the code completion just hasn't enabled the auto-popup feature.

So the big question is:

Is there any way to influence the code completion cache, or something I have to add to my code to make it work? I'd really like to have code completion for the methods I write.

PS: I have tried several older versions of netbeans, they all exhibit the same problem.

edit: I've put a .zip up of my current test project. get it here. It's a very young project, think a day and a half.

edit2: Below is a screenshot of what i'm looking at. As you can see, it fails to complete pretty much anything, nor does it see the PHPDoc documentation.

alt text

like image 770
Kris Avatar asked May 16 '09 22:05

Kris


People also ask

How do I enable completion code in NetBeans?

To invoke code completion press Ctrl + Space or, choose Source > Complete Code…

Does NetBeans have code completion?

Under Preferences -> Editor -> Code Completion is where you can find the auto complete properties. You can disable the 'Auto Popup Completion Window' to keep it from automatically popping. Also while the completion window is displayed, pressing the esc will close it without inserting an autocomplete value.

Can you code PHP in NetBeans?

NetBeans is an Integrated Development Environment (IDE) for developing PHP applications that makes it easier to create, edit, and test all of the HTML, CSS, and PHP files that you need for a web application.


3 Answers

I've tried opening your project, and the completion seems to be working just fine for me.

The only thing I can think of is to try to delete your entire NB cache, which should be located in $HOME/.netbeans/$VERSION/var/cache/. This is a wild guess

Create a backup first, I didn't try this!

If that fails, maybe you should try creating a new project, maybe that will kick NB in the butt.

Note that in NB 7.2 beta, the cache has moved to $HOME/.cache/netbeans/$VERSION.

like image 129
dr Hannibal Lecter Avatar answered Oct 01 '22 12:10

dr Hannibal Lecter


What worked for me was deleting the old nbproject folder (that was created in windows) and recreating the PHP project from existing sources. This is on NB 7.0.1 Mac OS X. Clearing the cache did not work for me.

like image 2
Jonathan Avatar answered Oct 01 '22 11:10

Jonathan


Be aware of @property something syntax. If object something does not exists in your code anymore, NetBeans might have problems with proper code completion. Consider example:

/** in main file: **/

use ABC as _ ;

/** in file ABC: **/

/** 
  *  @property \Something $something
  */

If you do not use $something anymore, NetBeans will most likely generate an exception, thus failing to complete the code.

like image 2
Michał Pilch Avatar answered Oct 01 '22 11:10

Michał Pilch