What is important in a PHP editor/IDE ?

I’ve been building websites for a while now. So i could say i am quite experienced although my (programming) knowledge is limited mainly focussed on building php applications. As a developer time is expensive, that’s why i am always looking for ways to speed up the web development process. A good start for fast & secure development is to have the right tools and the right feeling/connection with your editor.
On day-to-day basis i could say 80% of the time i have an open editor somewhere. Based on the amount of time you are “working together” with this piece of software, you could compare it to a marriage (although you shouldn’t trade wives as soon as you meet a younger, smarter and more beautiful girl).
I have a few expectations / requirements for a modern, good working editor

Decent Code Completion / Code Assistance

We all know word completion : auto completion involves the program predicting a word or sentence without the user actually having to type it in completely. This feature is used alot in text messaging (sms), email clients, browsers, search engines etc…
google_image_autocomplete
Autocompletion speeds up the entire process of typing a message, entering an address or, in our case, writing PHP code.
A decent source code editor analyses your source and suggests the function based on the first characters of the variable, function name or object. Most editors these days have code completion although they come in many flavours.
eclipse autocomplete
Larger web applications tend to use alot of classes & files. That’s what it is really important your autocompletion allows you to use an unlimited depth of super- & sub classes (inheritance). For this your IDE should have a decent understanding of the relation between classes. If in some case the code completion does not work for a certain object, you should be able to tell the editor which class your object belongs to, so it will allow you to use the code completion on next occurences of the same object/variable.

Code Documentation / PHPDoc

Another important aspect of code completion is documentation. It is very useful for a programmer to get as much visible feedback as possible about the method/function he is calling. For a php core function this should be a short summary what the function does, for custom methods/functions this would be the description as entered by the one that created the class/method.
eclipse_link
Next to that information it could be useful to show the return type and perhaps some information about the needed arguments. All these things should be integrated in the IDE, readily available when i enter the name of a method/class without opening a seperate manual or the php.net website.
When adding custom classes/methods/functions it is important that you document this code using phpdoc. Eclipse will then pick up this documentation and show it whenever you are using it somewhere else throughout your project.

Syntax Highlighting / Coloring

Code should look good. If you’re spending most of your time looking at code, it’s important to take care of your eyes. A good syntax highlighter highlights the different code to make a clear distinction between actual code, variables & documentation. Marking different type of elements in seperate colors will increase readability and help you understand a function faster.
Syntax highlighting also helps in finding errors in your code. Some editors mark incorrect code (missing delimiter, etc), this comes in handy when you are paying less attention. The editor will immediately show you you are doing something wrong…
Personally i prefer dark editors, many other programmers agree that this is alot better for your eyes. Next to that i find dark color schemes to be alot clearer and more beautiful to look at. TO give you an idea, this is what my eclipse looks like :
screenshot1

Code Bookmarks

When we are writing code it is important to keep track of important locations throughout the project. Code Bookmarks is the easiest way to do it.
A good implementation of bookmarks should allow you to easily switch to next/previous bookmark and give you an overview/listing of the current “bookmarks”.
screenshot3
If you look on the left side, you will see a small flag that marks the current line as being bookmarked.
screenshot7
Once you have these “code bookmarks”, its hard to code without them.

Smart/Quick opening

Now where did i put this code/file again ? Which class defines the foo() method ? Most of you will agree with me that opening the correct resource/file/method takes alot of time. A good editor should allow you to find/open everything you are looking for with a few keystrokes and (more important) without touching your mouse.
My favourite editor (Eclipse) allows you to use ctrl+shift+R to “open resource” and quickly find the file you were looking for.
screenshot8
This means i do not need to touch my mouse or open the “file explorer” to look for the file. Easy & Fast…
I know some people who use “grep -r ‘ methodname()’ to find the location of a method. I personally think this stinks. A good editor should contains some ways to easily open a file/method.

Class Outline

It’s easy to lose track of the variables/methods that are defined in a class. This is where the “outline view” comes in handy. This “outline” view will give you a the overview of every method/variable defined.
screenshot9
Double clicking a method will take you to this method. No search, no scrolling, no touching the mouse. In eclipse there is an even better way. Once inside a class you can use CTRL+O to get a quick outline with autocomplete functionality, finding the method you were looking for never was this easy…
eclipse quick outline
Thanks Eclipse :)

Platform Independance

If you are a regular reader of this blog, you will know we are using several linux flavours in our office. So for us it is very important t he same editor can be used on Windows & Linux platforms. Most “multi-platform” ide’s are based on java (zend, eclipse,…) but there are some other ide’s that have clients for both platforms.

No comments:

Post a Comment