Automatic code formatting for PHP in your editor or CVS/SVN

PhpCodeBeautififier is a free tool for PHP programmers that formats PHP files to get a nice presentation and keeps the programmer sanity. We all programmers have our own way of representing code lines, but when the code is shared amongst many programmers it has to be formatted following some conventions.

PhpCodeBeautifier allows you to specify those patterns you'd like to follow and it will format every file for you. The idea is simple, you continue on being that little unchangeable typer and delegate the "boring" part to that tool. You can work for several companies having diferent coding standards, but you keep always programming your way, look at the exagerated non-sense sample:

Sample of phpCodeBeautifier It certainly looks better! So with that tool you and your colleagues can work each one following the personal style and when code has to be merged in the community you pass that final code through the Beautifier for getting an homogeneous code, in the way you all have agreed.

PhpCodeBeautifier is available both for Windows and Linux. In the earlier version (0.77) there is a GUI for windows in addition to the command line (though the command line is the only one I am using). That's a shot on how it might look like the pattern definition: PHPCodebeautifier So, now you are thinking. Ok, that's nice, but I have to invoke all the code through the command line/GUI every time? No, keep on using your favorite IDE and integrate it, or just call the tool directly on the versioning system (CVS/SVN). Beautifier is available under the PHPEdit editor, but as I usually work with Eclipse's PHP Development Tool I followed that simple steps to have it running under the "External Tools" (a couple images are worth thousand words): Eclipse external tools Eclipse external tools

And that's it.

Update: A sample screenshot on how it's integrated with subversion pre-commit hook.

Precommit hook sample