views:

423

answers:

2

I am seeking a Linux or PHP program to automate code formatting. Optimally it would handle many languages, but the priority is (highest first): PHP, JavaScript, HTML, CSS and MySQL. Comparability is nice, but not the most important feature.

Context / use: automation via Subversion post-commit. I'm working with teams and want to always follow a single method of formatting.

A: 

I find that using an IDE such as Eclipse or Aptana will accomplish this task very easily. It's not automated but if all developers use an IDE this is very simple

Phill Pafford
I'm working with some people who definitely won't be using an IDE, but that's a helpful suggestion for some none the less. Thanks.
A: 

Astyle is the canonical answer if you insist on just one.

You likely cannot get a single formatter for many langauges that understands their syntax, and you can't afford to get the syntax wrong, because you don't want the formatter to break code (especially after it has just been checked in!) [Astyle works on several because it accepts only C-like langauges]. See Semantic Designs Formatters for such tools for many langauges that do understand syntax accurately and can't make such mistakes.

Ira Baxter