Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am in search for a - preferably free - php ide with working autocompletion aka IntelliSense™. I have been working with NetBeans for a couple years, hoping the php support would become somewhat mature. But still it seems the singleton pattern is not supported.

$oDatabase = new MainDB();
$oDatabase->

autocompletes.

$oDatabase = MainDB::getInstance();
$oDatabase->

does not autocomplete.

$oDatabase = new MainDB();
$oDatabase = MainDB::getInstance();
$oDatabase->

DOES autocomplete, although $oDatabase was overwritten by the second line. BTW MainDB::getInstance() has a defined return type MainDB via phpdoc.

share|improve this question
1  
I left full fledged IDE's months ago for a combination of GNU Screen and VIM with plugins. Can't say I've found anything I can't do with vim, using 5% of the memory (although getting everything configured takes time and dedication on its own). It's not for everybody, but I have to say it's the most usable "IDE" I've ever used. – Craige Sep 28 '11 at 14:17

closed as not constructive by gnat, Martijn Pieters, Kilian Foth, thorsten müller, Frank Apr 9 at 13:05

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

6 Answers

I've been using PHPStorm for a while now, it's very good at what it does (it's made by jetBrains, the same people behind reSharper)

share|improve this answer
1  
Totally agree. PHPStorm does this no problem. I made a small wrapper for the PDO class and calling $dbh = PDO_WRAP::OpenSesame(); yields exactly the autocomplete functionality on $dbh that the OP is requesting. EDIT - I also started with NetBeans and switched over, FWIW. No going back for me :-) – Andrew Heath Sep 29 '11 at 5:32

Does MainDB::getInstance() have a @return tag in the doc block? Without that there is no way for an IDE to know the type of a variable.

Else you can declare the type of the variable:

/* @var $oDatabase MainDB */
$oDatabase = MainDB::getInstance();

See also: http://netbeans.org/kb/docs/php/editorguide.html#vartyp-cmnt

share|improve this answer
I'm expecting this will probably be the problem. – Craige Sep 28 '11 at 14:18
I am quoting my question: "BTW ´MainDB::getInstance()´ has a defined return type ´MainDB´ via phpdoc." Furthermore there is a way for the IDE to know the variable. It could just look at the code. I am merely a human being and I can easily find out the type of a variable. And how does the interpreter do it? Mysterious ... – Leif Sep 28 '11 at 17:09
All I can say is that I didn't have problems with proper @return tags. this doesn't have to mean anything, maybe I was lucky. I can also say that my bug reports were handled nicely. But again: I could be lucky. – johannes Sep 28 '11 at 17:11

For me personally I swear by PHP Development Tools for Eclipse. It's got the intellisense that I want, and can even be tied into your server to use for testing purposes as well, with the added benefit of other plugins that support SCM (From Git, to Hg, to SVN and CVS) and multiple other languages (coming from Eclipse itself), I'm actually kind of surprised no one's offered it up yet.

share|improve this answer

I use netbeans for years now and this kind of autocompletion works well if you use proper php doc comment style, with the class name for the return value type or the the class name when you declare a variable in a class

/**
 * Your var declaration
 * @var My_CLasss
 */
private static $_instance=null;

or/and

/**
 * Get the object instance
 *
 * @return My_CLasss
 */
public static function getInstance()
{
   if( is_null(self::$_instance) ) {
      self::$_instance = new My_CLasss;
   }
   return self::$_instance;
}

enjoy ;)

share|improve this answer

I use Netbeans and find it fine with PHP singletons (say from Propel). @johannes has already mentioned a phpDoc return type - that's the first thing I'd check.

Also, try adding your lib folder (containing the singleton definition) into your PHP Include Path config in your Project Properties. If it is within your project you shouldn't need this, but it does no harm to try this additionally (and if it is outside your project, you will definitely need this).

share|improve this answer

I was in the same boat a while ago, with python. I ended up going with vim. You start out with an extremely powerful editor, and add in the functionality you want.

In your case, snipmate and supertab make using snippets and omnicomplete (vim's version of intellisense) a breeze. ConqueTerm gives you a command line, and project lets you view your project files.

While I don't entirely agree with him, Steve Losh's blog post will show off some of the powerful vim text editing features. A better post, both on why you should switch, and how to learn vim, is this one.

I tried several other fully fledged IDEs before I started with vim. Nothing comes close to providing the functionality, power, or flexibility of vim. If you like a certain feature of your current environment, it may or may not be in your new IDE. And there isn't any way to get it there if you want it!

That's the fundamental difference between going "ground up" from vim. An IDE is a turn key package. It's supposed to be ready to go. But if you can't find one with all the features you want/need then your out of luck. Vim doesn't start ready, but once you get there, you have everything.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.