Update: adjusted the PHP Beautifier instructions slightly as per @h
For PHP code, my favorite formatter is the PHP_Beautifier PEAR module, which helpfully installs a 'php_beautifier' script you can run from the command-line. All I did was install PHP_Beautifier via PEAR:
pear install PHP_Beautifier-beta
This should install the 'php_beautifier' script; I'm using MAMP on my MacBook so mine ends up in
To integrate this script with Komodo, do the following:
- Open Komodo's preferences window and click on 'Formatters' on the left-hand side
- Click on the green 'Plus' button to add a new formatter:
- Type in the following:
Name: PHP Beautifier ( or whatever )
Formatter: Other Formatters => Generic Command-line Formatter
- For 'Executable to use', paste in the full path path to the 'php_beautifier' script.
- For the command-line arguments, paste in the php_beautifier options you would like to use.
Now, how you would want to format your code is entirely up to you. I f you;re developing Drupal code, you might want to look at their style guide; for other projects, YMMV. For my own development, I have arrived so far at this:
-s4 -l "ArrayNested() NewLines(before=if:switch:T_CLASS:function:T_COMMENT:T_VAR,after=T_COMMENT:function)"
The nice thing is that you could create several of these for different code formatting standards.