tags:

views:

161

answers:

9

I am looking for a program, free or cheap, that formats the PHP code nicely. Sometimes I do copy and paste and the formatting looks screwed up. I found online source formatting but I would like to have a standalone program or an extension in my Dreamweaver (Windows) as it would be nice if I could apply source code formatting for all my PHP pages along with HTML. Dreamweaver only formats XML-based source, it leaves PHP source code untouched.

+2  A: 

PHPTidy Does exactly what you're looking for. Quite a useful tool.

GSto
+2  A: 

Eclipse PDT should do the trick, if you're willing to switch to that.

Peter
A: 

Eclipse with the PDT.

Daniel Bingham
+1  A: 

In most good IDEs you can select all the code and then run what is usually the "indent" command which will automatically indent the code properly.

Joe Philllips
A: 

Polystyle is all right, very configurable and works for many languages. You can set very detailed formatting rules, even using live examples. Costs something around $15.

Pekka
A: 

I use Crimson Editor or Notepad++

Vinicius Jarina
A: 

I sometimes use PHP_Beautifier, which can be executed as a standalone tool from the commande-line, and does a really great job when you pass it the "right" options.

For every-day use/work/coding, Eclipse PDT, as an IDE, is a nice choice, too -- provided you have a powerful enough computer.

Pascal MARTIN
+1  A: 

vim or emacs. :-p

just_wes
Why the downvote? In vim type "==" and it will format the specified region of php code. In emacs use indent-region, and it will format the region for you. Furthermore, both vim and emacs are free and open source. I don't see a problem with the answer I supplied aside from a gratuitous emoticon. Please explain your criticism next time.
just_wes
'guess it must have been the emoticon, chief ;))
luvieere
ps: I'm not the downvoter, I just drew a conclusion
luvieere
In vim: (1) copy/paste php code in window (2) enter command :set filetype=php (3) gg=G
mike
A: 

Eclipse PDT is really the best way to go if you have more than one file you plan on formatting. I use it regularly since it allows you to specify how to format your code by setting the syntax style in the options.

After all, your style may not be mine!

Xeoncross