![]() |
![]() |
![]() |
Script use | How to use PHP_Beautifier | PHP_Beautifier_Batch documentation |
First, you should know where the script resides. The Pear installer puts the script on the PHP binary directory or in PHP_PEAR_BIN_DIR if defined. So, in linux, the script php_beautifier is included in the path of executables (/usr/bin/php_beautifier). On Windows, a batch file called php_beautifier.bat is created as a wrapper for php_beautifier
First, put the path where resides the php_beautifier.bat executable on PATH, and type on a console window :
c:\>php_beautifier [commandline]
By default, the script is located in the path of executables, with execute permitions, so you only have to type:
$ php_beautifier [commandline]
File name(s) (allowed * and ? for batch processing) or - for STDIN.
Path to a dir (with '/' at the end), to a single file (without the '/') or - for STDOUT
Set compression. Modes can be 'gz' (default) and 'bz2'
The name of the filter should be written in StudlyCaps. The settings are inside the parenthesis, separated by commas; the value is preceded by '='. Other Filter could be added, separated by spaces.
The default input/output of the tool are STDIN/STDOUT. So, don't be surprise if nothing happens when you call the tool without any options!
short option | long option | description |
-f | --input | input path |
-o | --output | output path |
-c | --compress | Compress the output ('tz','bz2') |
-t | --indent_tabs | Indent with tabs |
-s | --indent_spaces | Indent with spaces |
-l | --filters | Add one or more filters |
-d | --directory_filters | Add a filters directory. |
-r | --recursive | Turn on recursive mode |
-? | --help | Display help / usage |
Set the input pattern for beautify. * and ? are allowed for batch processing. If recursive mode ( -r) is turned on, the pattern may catch directory names. - get input from standard input
Set the output for beautify. If the param ends in '/' and the input matches one or more files, the program try to recreate the input directory structure. If the param doesn't end in '/', the output will be one file. - set the output to standard output
Set compression for output file(s). You can select 'gz' or 'bz2'. If output is a dir, all the files are compressed separately!
Tabs are used as indent char. Without a param, the number of tabs for indent is 1
Spaces are used as indent char. Without a param, the number of spaces for indent is 4
Add one or more filters to the process. Look on Usage the definition for the command
$ php_beautifier --filters "ArrayNested Pear(add_header=php)"
Add a path to lookup for filters. See PHP_Beautifier::addFilterDirectory().
Turn on the recursive search for files inside directories. On *nix, remember to quote the input_path
Show the help / usage.
We have this files structure. Current directory is /myprogam/
/myprogram/index.php /myprogram/file1.php /myprogram/file2.php /myprogram/lib/lib.php /myprogram/lib/lib1.php /myprogram/lib/lib2.php
Send the output to STDOUT
php_beautifier index.php
This match only the files inside /myprogram/ . The output is send to STDOUT
php_beautifier *.php on *nix php_beautifier "*.php"
This match all the files inside /myprogram/ and /myprogram/lib . The output is send to STDOUT
php_beautifier -r "*.php"
This create a new file with 2 spaces for indentation
php_beautifier -s2 index.php index_new.php
This create a new file with 2 tabs for indentation
php_beautifier -t2 index.php index_new.php
Use PEAR standards
php_beautifier -l "Pear()" index.php index_pear.php
Use PEAR standards, add Apache license, nest arrays and list the functions and classes of file
php_beautifier -l "Pear(add_header=apache) ArrayNested() ListClassFunction()" index.php index_new.php
Beautify all the files and send the output to one file
php_beautifier -r "*.php" all_files.txt
Beautify all files and recreate the dir structure on ./myprogram-beautified/
php_beautifier -r "*.php" ./myprogram-beautified/
![]() |
![]() |
![]() |
Script use | How to use PHP_Beautifier | PHP_Beautifier_Batch documentation |
Documentation generated on Mon, 05 Jun 2006 22:52:39 -0400 by phpDocumentor 1.3.0RC6