Do you know any good tools for nicely formatting messy php code? Preferably a script for Aptana/Eclipse, but a standalone tool will do too.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Our PHP Formatter will reliably format your code. It uses a compiler-based front end to parse the code, so it doesn't misinterpret the code and damage it. Consequently its formatted output always works.
There's a pear module that formats your code. PHP Beautifier
Use NetBeans PHP and press alt+shift+F.
What about this one:
http://universalindent.sourceforge.net/
It combines a bunch of formatters out there, and will generate the scripts you need so you can pass them out and get your team members to use them before committing next time... Though... formatters might mess up your code and render it unusable...
PHP Code Beautifier is a useful free tool that should do what you're after, although their download page does require an account to be created.
Basically, it'll turn:
into
I've been having a lot of trouble finding a decent free formatter for PHP as well, there are many online and command-line tools but they just don't seem to work for some reason, the results are all still full of bad indenting with combinations of tabs and spaces, and they never get the braces the way you want them!
I tried the snippet above and that didn't work for me either, indenting still full of spaces and tabs all mixed up.
So I've had a go at writing a simple one too, this one just uses all regex, no fancy compiler magic, so it's possible that it could break things, and is still very beta and being tested on various messy code. The interface is very basic at the moment too, but should improve over the next few days.
It's hardwired for MediaWiki's conventions, but you can modify it pretty easily (I may add options later).
https://www.organicdesign.co.nz/Special:CodeTidy