I've attached a zip file containing a php script and a Macro that provides decent PHP code re-formatting using the Pear PHP_Beautifier extension[1]. To get this running requires a little bit of work:
1. install the module from pear:
pear install PHP_Beautifier
note: you may need to first run
pear config-set preferred_state beta
As well, this module I believe requires PHP 5.
2. unzip the attached zip file, import the kpz package into your toolbox, then place the script 'phpbeautifier.php' in some directory. You will need to edit the Macro:
You will need to edit this line:
var script = "/Users/jeffg/code/php/phpbeautifier.php"
...and change the path to be the full path to phpbeautifier.php on your system.
Once this is done, you should be able to open any php file and run the beautifier on it. The code style I am using is 2-space indent and K&R bracing formatting roughly, and you can always edit phpbeautifier.php to adjust these settings.
[1] http://pear.php.net/package/PHP_Beautifier
| Attachment | Size |
|---|---|
| beautifier-1.zip | 2.72 KB |
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Even when entire location line is quoted.
Well, I only tested this on OS X, so I'm not completely surprised. What files are you trying to beautify? What is the full path?
--
JeffG | Komodo IDE 4.0 | MacBook Pro OS X Intel / Ubuntu 6.10 i386
pear install PHP_Beautifier-beta
First of all, thanks for the script Jeff it's very good, It works great under linux but I can't manage to add a new line after every function, if I add 'after' => 'function' it adds a line after the functions signature, I would like to have a line between every function, any idea how I can do that?
phpbeautifier.php http://pastebin.com/m1ccdb9ad Thanks in advance
The NewLine filter in PHP_Beautifier has not worked to my satisfaction in my experience. I always get new line between phpdoc and function and other unexpected new lines. It seems like I am stuck with default PHP_Beautifier settings. Maybe it's just my setup. I would prefer if Kommodo IDE supported PHP formating by default.
CentOS, php 5.2.16.
Isn't it possible to save remote files temporaly local , run PEAR with the beautifier, and put the text back in the file ?
Because it is not possible to user the beautifier on remote server...
djangoboy [at] gmail [dot] com
That's quite possible, you'd have to implement that in a macro, outside of Komodo IDE's formatters feature. It could definitely work though.
--
JeffG
http://www.openkomodo.com/blogs/jeffg