Formatting PHP code in Eclipse PDT and Zend Neon

Submitted by Frederic Marand on Tue, 2007-08-21 09:24
By default, the current Eclipse-based PHP IDE (PDT) uses an indenting style based on One True Brace, and the upcoming Zend Neon version happens to be also Eclipse-based. For developers working with OSInet Drupal modules or PHP-GTK code, or anyone wishing to apply the OSInet coding style, or another form of Whitesmiths / Symbian PHP formatting, Eclipse allows for customizing the bracing/commenting style by hand-tuning, or to make things simpler, by just importing the OSInet rules for Zend Studio / Eclipse PDT.

It's really simple, at least in Zend Studio Neon: go to Preferences/PHP/Formatter.

Then click on Import and choose the XML file with the conventions. If conventions by the same name exist, you will be asked whether to override them or rename the imported conventions. Apply, and you can now use them.

Not sure how how this relates to the default PDT system, though.

In Eclipse 3.4 the PDT environment does not have an import option under preferences @ PHP > Code Style > Formatter to import the Osinet profile from the supplied XML. Should I try to import at PHP > Code Style > Code Templates?

code templates are different from the formatter. code templates work with the auto complete function. so if you have code template for say drupal hooks which then you can import these at PHP > Code Style > Code Templates and have them trigger options available when you type "hook_" ctrl+space

This is different from formatter which will clean up the page and bring {} to where you want them etc.

PDT only has 2 formatting options spaces and indentation size. PHPeclipse has more code formatting options but doesn't do remote debugging with xdebug yet. there is no perfect option.