Skip to content

PHPeclipse Annoyances

I have become an Eclipse convert. Eclipse is an IDE which I use to develope my PHP projects. Eclipse is open source and free, and has too many features to even begin listing. It also has a myriad of modules supporting language specific extensions and support for programmer tools like CVS.

I've also been using the PHPeclipse extension, which adds a number of nice PHP specific features and in eclipse terminology, an eclipse perspective, which is especially useful if you develope in an all-in-one environment with a local apache and php instance on your workstation. This allows you to iterate rapidly, as your changes can be instantly examined in the docked browser window, and ostensibly give's one access to php's debugging hooks. I'll admit I've never tried this, although having a debugger available is always a nice feature for any platform.

The main things I want out of PHPeclipse are color syntax hilighting, a class and function browser window that makes it quick to jump around inside your code, and PHP functionn prototypes so I know what the argument list is for all those useful built-ins like substr and array_sort, all of which you get with PHPEclipse. The class browser works well, except that it's not smart enough to resolve includes, and for this reason, rarely has visibility into the classes you're using because they're in their own class file. You can always open these in a seperate source window of course, as your workspace you can have numerous files open, all easily accessible from tabs.
Despite its current limitations, PHPeclipse provides php and web development features that make eclipse a serious competitor to the other php IDE's out there, and has the benefit of being absolutely free, not to mention cross platform.

The extension has a lot of features I haven't described, and some of them, I find to be annoyances. Getting the most out of the plugin means getting into the preferences as quickly as possible and tweaking them to your liking. For example, by default phpEclipse provides a bunch of autocompletion features. If you are entering a string that you want to break across several lines like this:


$s = "This is line 1
and line 2
and line 3"
;
 


PHP has no problem with string broken across multiple lines like this. I use this facility extensively when coding embedded SQL statements.


$sql = "SELECT name, created
             FROM users
             WHERE userstate = 0
              ORDER BY created DESC"
;
 


The problem with phpEclipse is that it tries to outsmart you and add end quotes and will even go so far as to auto-concatenate these lines for you, when you hit enter, so in the example above, after typing the first line you will now see:


$sql = "SELECT name, created" .
"FROM users


Although it's not entirely intuitive, eclipse preferences are accessed from the window menu. You'll see Preferences at the bottom.


With PHPeclipse installed I think the first thing most people will want to know is how to find the PHPeclipse preferences for the autocompletion functions you will probably find just get in your way. The other reason to get into the PHPeclipse configuration section is to configure some of the features you may find useful. For example, when you use the PHPeclipse perspective and create a new php file, it will add a header section for you automatically. You could have this be a standard set of PEAR/phpDocumentor comments and embedded tags.




Once inside the Preferences you'll see a phpEclipse section. Click on the (+) to open it up. Snoop through the many available options, but make sure you start with the php submenu.





From the PHP submenu dialog, choose Editor and click on the Typing tab. I've indicated the items you might want to uncheck. These include:

  • Wrap Words

  • Wrap Double quoted strings (from the example above)

  • Wrap Single quoted strings

  • Close double quoted strings

  • Close single quoted strings

  • Close brackets and parenthesis

  • Close PHPDocs and comments




The Wrap options are the ones that cause the most trouble, while the rest are things you might find you like. For example, the ability to pair quotes, double quotes, brackets and parenthesis. When you type a starting bracket, it will imeediately provide you an end bracket. I find this to be a time saver so I leave a few of these options on, as noted in the screenshot.

Remeber to click the apply button when you're done setting your configuration. Hopefully this will save you some time in getting PHPeclipse set up as your PHP development environment.
Defined tags for this entry: , , ,

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Pavatar, Gravatar, Favatar, MyBlogLog, Pavatar author images supported.
BBCode format allowed
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
Form options