Using PHP Beautifier with Komodo IDE

komodo ide blog hero

Update: adjusted the PHP Beautifier instructions slightly as per @h
Komodo IDE recently added a code formatting feature, including built-in formatters for javaScript and HTML/XML. This is great, but the first thing I wanted to do was format PHP code! Luckily Komodo also allows the ability to add new formatters by hooking into existing command-line utilities.
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:

  1. Open Komodo’s preferences window and click on ‘Formatters’ on the left-hand side
  2. Click on the green ‘Plus’ button to add a new formatter:
  3. Type in the following:
    Name: PHP Beautifier ( or whatever )
    Language: PHP
    Formatter: Other Formatters => Generic Command-line Formatter
  4. For ‘Executable to use’, paste in the full path path to the ‘php_beautifier’ script.
  5. 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.

Recent Posts

Webinar - Walking Dead Past Python EOL
Walking Dead Past Python EOL

With Red Hat dropping Python 2 support, more organizations will be stuck maintaining zombie legacy apps. Stop racing against EOL dates and letting bad practices infect your new projects. Get current and stay current with the latest open source language versions.

Read More
Scroll to Top