Question

Despite what some might say, I believe that code completion (aka Intellisense) is the second best invention when it comes to code editors (the first being syntax coloring). It really makes coding easier because I don't have to worry whether I named the function CalculateReportSums, ReportSumsCalculate or simply GetReportSums.

Unfortunately I have not yet found a code editor which would satisfactory implement this feature for PHP. And by "satisfactory" I mean "as good as Visual Studio for C#".

My first choice of text editor is Notepad++, but that only has a list of PHP's built-in functions, and it only appears after you hit Ctrl+SPACE. I've also tried Eclipse+PDT, which is better, but still often has hiccups, sometimes fails altogether for no apparent reason (no list available), and always appears only when I pause typing (setting the timeout to some small value causes the list not to appear altogether).

So - is there something better out there? Something that would be aware of all the variables in the current scope, that would be able to follow include()s, and would display the list in real-time as I type?

I know that PHP is a dynamic language and a perfect code-completion is impossible in principle (because you don't know what variables will be there until runtime), but it should still be possible to implement it to a fairly good degree - much better than what I've seen so far.

Added: To add a few minor points - I want the CC to be instantaneous, like in Visual Studio. I type a character, and the list shows at the same instant. I type another character and the list becomes half the size before I can even blink. Near-zero CPU usage, instantaneous results (all hail the Gods of caching!).

Also - I'm fine with documenting my functions and even variables in a special way. I prefer PHPLint syntax (because then I can check my code with it later), but other syntaxes will do as well. Forcing to do this is also good for your commenting discipline. :)

Was it helpful?

Solution

I have found that Netbeans has better code completion than Aptana. When I was working with codeigniter, Netbeans would code complete for my static methods in models where Aptana wouldn't.

Since my posting of this, JetBrains has released PHPStorm and has your rapid fire intellisense, as well as even better type hinting. It is absolutely superior to all others IMHO. I've been using EAP 2.0 for several months now for free.

OTHER TIPS

You're right that intellisense is much more complicated in a dynamically typed language like php. Consider for example

  function get_foo($x) {
       return $x ? new abc() : new xyz();
  }

  get_foo(123)->... can your IDE autocomplete here?

Don't know about PDT, but Netbeans is unable to handle this, and phped requires 'get_foo' to be annotated in a special way.

I haven't yet tried the upcoming WebIDE from Jetbrains (http://www.jetbrains.com/webide/features/index.html), but looks promising in this regard (see screenshot).

No doubt, use NetBeans, is very usefull and have a good intelisense (okay, not is perfect) but is better than Eclipse for example.

I recommend you netbeans .its free. it is available for all platforms, and mostly it is good for editing php, jsp, java, css, html, ... Good for SVN, mercurial, Plus you can integrate it easyly with kenai.com...

it helps with the IntelliSense kind of pop up.

believe me, i'm using it for php development and its the best suited ide i can find...

I use PHPEd (http://www.nusphere.com/) which has a workable version of this feature.

note: They have an offer listed on their front page. Ignore this. It has been ending tomorrow for at least 4 years now.

I take it you are on Windows. In windows I usually use phpDesigner (http://www.mpsoftware.dk/phpdesigner.php) which has pretty good CC. In linux, I use geany(http://www.geany.org/) or vim both of which have CC, in the later case, you will need to set it up. I found Eclipse to be too bloated and I got sick of waiting for it to startup. :\

Kimodo has good code completion, revealing not only the functions in PHP, but the stuff that you've got declared in the current context. Additionally, if you've properly documented your function or whichever, it displays that documentation as well!

I have yet to see anything top the Auto Completion that was in Zend Studio 5.x. I have tried later versions, which are built on Eclipse, and well might as well be using Aptana...

Unfortunately this means keeping windows with the XP or 2000 look since the Java GUI (the one Zend Studio was built on) screws up in Win7 Look, but for the features Zend 5 has, it is well worth it.

Not only will it auto complete known functions, it will autocomplete variables/functions you make, and not only for your current file, but any open file (and I think any in open project), and will auto suggest Class items as well.

Plus being able to run local inside Zend Studio itself for testing parts of code is great. If only it easily let you save to both local file system and upload to the server at the same time.... (I just let a FTP program running in the background that every 10 minutes will download any changes to the server).

vim.

http://weierophinney.net/matthew/archives/123-Vim-7-code-completion.html

Also, looking at the recommended similar questions, I noticed there is already a good question discussing the different ways to use vim code completion.

Word / Code Completion in VIM

You can try Zend Studio.

http://www.aptana.org/

Code Assist
Aids in authoring of HTML, CSS, JavaScript, PHP, and Ruby. Supports the latest HTML5 specifications. Includes information about the level of support for each element in the major web browsers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top