Source code formatter

Anyone know of a good PHP source code formatter?

I don’t mean color coding, but source code reformatting.


  • Written in PHP

  • Correctly indents using spaces (not tabs) and follows the general style/layout of the Yii codebase

  • Proper formatting and indentation of PHPDOC-style comments

Any recommendations?


Are you looking to format your HTML output?

If so, you can use PHP tidy functions. If tidy isn’t installed (it never is), you can use DOM functions to read and output formatted.

Something like this…might need tuning…

$dom = new DOMDocument;

$dom->validateOnParse = false;

$dom->formatOutput = true;



No, I’m looking for a PHP source code formatter - not HTML.