Using PHPCB to add PHP code beautification tools for EditPlus can be integrated into EditPlus or other editors with PHP code formater: phpCodeBeautifier (phpCB for short. It beautifies the PHP code format and makes the messy PHP code neat. After EditPlusr is installed
Use PHPCB to add PHP code beautification tool for EditPlus
PHP code formatting tool that can be integrated in EditPlus or other editors: phpCodeBeautifier, phpCB for short.
It beautifies the PHP code format and makes the messy PHP code neat.
After EditPlusr is installed, you can choose tools> configure user tools from the menu bar, choose User Tools> Add Tools> Applications ].
Menu text writing: PHP code beautification; command: Select the local storage address of phpCB.
Parameter write: $ (FilePath) or the following content (the command is a line). For details, see phpCodeBeautifier User Manual.
-- Space-after-if -- optimize-eol -- space-after-switch -- space-after-while -- space-before-start-angle-bracket -- space-after-end-angle -bracket -- extra-padding-for-case-statement -- glue-amperscore -- change-shell-comment-to-double-slashes-comment -- indent-with-tab -- force-large -php-code-tag -- force-true-false-null-contant-lowercase -- comment-rendering-style PEAR -- equal-align-position 50 -- padding-char-count 1" $ (FilePath)"
Initial Directory: $ (FileDir)
Finally, select "run text filtering". in the drop-down box, select "replace,
In this way, our PHP code beautification tool has been added,
When you need to use it, you only need to select the PHP code beautification tool in the menu bar,
The program will automatically organize our messy code to make our code more beautiful and easy to read and analyze.
Http://www.waterproof.fr/products/phpCodeBeautifier/manual.php
PhpCodeBeautifier User Manual
Options
-- Space-after-start-bracket: Allow to insert a space after start bracket "(".
With -- space-after-start-bracket Without -- space-after-start-bracket
If ($ condition ){
}
?>
If ($ condition ){
}
?>
-- Space-before-end-bracket: Allow to insert a space before end bracket ")".
With -- space-before-end-bracket Without -- space-before-end-bracket
If ($ condition ){
}
?>
If ($ condition ){
}
?>
-- Space-after-if: Allow to insert a space after "if" keyword.
With -- space-after-if Without -- space-after-if
If ($ condition ){
}
?>
If ($ condition ){
}
?>
-- Space-after-switch: Allow to insert a space after "switch" keyword.
With -- space-after-switch Without -- space-after-switch
Switch ($ condition ){
}
?>
Switch ($ condition ){
}
?>
-- Space-after-while: Allow to insert a space after "while" keyword.
With -- space-after-while Without -- space-after-while
While ($ condition ){
}
?>
While ($ condition ){
}
?>
-- Space-before-start-angle-bracket: Allow to insert a space before starting angle bracket "{".
With -- space-before-start-angle-bracket Without -- space-before-start-angle-bracket
While ($ condition ){
}
?>
While ($ condition ){
}
?>
-- Space-after-end-angle-bracket: Allow to insert a space after starting angle bracket "}".
With -- space-after-end-angle-bracket Without -- space-after-end-angle-bracket
While ($ condition ){
} // End of while
?>
While ($ condition ){
} // End of while
?>
-- Extra-padding-for-case-statement: Increase padding before case statements.
With -- extra-padding-for-case-statement Without -- extra-padding-for-case-statement
Switch ($ condition ){
Case 1:
Action1 ();
Break;
Case 2:
Action2 ();
Break;
Default:
Defaultaction ();
Break;
}
?>
Switch ($ condition ){
Case 1:
Action1 ();
Break;
Case 2:
Action2 ();
Break;
Default:
Defaultaction ();
Break;
}
?>
-- One-true-brace-function-declaration: Use "One true brace" formating for functions.
With -- one-true-brace-function-declaration Without -- one-true-brace-function-declaration
Function aFunction ($ param)
{
// Function content
}
?>
Function aFunction ($ param ){
// Function content
}
?>
-- Glue-amperscore: Glue "&" to following item.
With -- glue-amperscore Without -- glue-amperscore
$ Value = & $ objectInstance;
?>
$ Value = & $ objectInstance;
?>
-- Change-shell-comment-to-double-slashes-comment: Change "#..." comment into "//..." comments.
Source With -- change-shell-comment-to-double-slashes-comment Without -- change-shell-comment-to-double-slashes-comment
# Comment content
// Another comment
?>
// Comment content
// Another comment
?>
# Comment content
// Another comment
?>
-- Indent-with-tab: If selected, tabulation (ASCII #9) character is used to indent text, elsewhere space (ASCII #32) character is used.
-- Force-large-php-code-tag: Change" "Into"?> ".
Source With -- force-large-php-code-tag Without -- force-large-php-code-tag
?>
<%
%>
?>
?>
?>
<%
%>
-- Force-true-false-null-contant-lowercase: Lowercase for NULL, TRUE and FALSE constants as encouraged in PEAR coding standards.
Source With -- force-true-false-null-contant-lowercase Without -- force-true-false-null-contant-lowercase
If (TRUE ){
If (FALSE ){
$ Value = NULL;
}
}
?>
If (true ){
If (false ){
$ Value = null;
}
}
?>
If (TRUE ){
If (FALSE ){
$ Value = NULL;
}
}
?>
-- Align-equal-statements: Align all assignement statements.
Source With -- align-equal-statements
$ NoError = true;
$ FeildEmpty = false;
$ ShowMessage = false;
$ ShowMessage = false;
$ AnotherVariable [0123] = \ 'bla bla \';
$ ShowBlaBlaBlaMessage = false;
?>
$ NoError = true;
$ FeildEmpty = false;
$ ShowMessage = false;
$ ShowMessage = false;
$ AnotherVariable [0123] = \ 'bla bla \';
$ ShowBlaBlaBlaMessage = false;
?>
-- Align-equal-statements-to-fixed-pos: Align all assignement statements to a fixed position.
Source With -- align-equal-statements-to-fixed-pos 30
$ NoError = true;
$ FeildEmpty = false;
$ ShowMessage = false;
$ ShowMessage = false;
$ AnotherVariable [0123] = \ 'bla bla \';
$ ShowBlaBlaBlaMessage = false;
?>
$ NoError = true;
$ FeildEmpty = false;
$ ShowMessage = false;
$ ShowMessage = false;
$ AnotherVariable [0123] = \ 'bla bla \';
$ ShowBlaBlaBlaMessage = false;
?>
Comment rendering style
The following style of comment formating are available:
-- Comment-rendering-style PEAR -- comment-rendering-style PHPDoc
/**
* Bla
*
* @ Access public
*/
?>
/**
* Bla
*
* @ Access public
*/
?>
PEAR Coding standards Tips
To follow PEAR coding standards, I recommend you to use the following configuration:
Option State
-- Space-after-start-bracket-
-- Space-before-end-bracket-
-- Space-after-if X
-- Space-after-switch X
-- Space-after-while X
-- Space-before-start-angle-bracket X
-- Space-after-end-angle-bracket X
-- Extra-padding-for-case-statement-
-- One-true-brace-function-declaration X
-- Glue-amperscore X
-- Change-shell-comment-to-double-slashes-comment X
-- Indent-with-tab-
-- Force-large-php-code-tag X
-- Force-true-false-null-contant-lowercase X
-- Align-equal-statements X
-- Align-equal-statements-to-fixed-pos-
Use 4 for the padding character count to use.
Command Line
Command line syntax is the following:
PhpCB.exe [options] [srcFile]
Where options is from the previous topic list and srcFile is the file to beautify. if no srcFile is given, standard input will be used. the transformed text will be outputted to standard output, you can redirect it to a file using the> symbol.
Example
This is a sample call of the command line version:
# PhpCB -- space-after-if \
-- Space-after-switch \
-- Space-after-while \
-- Space-before-start-angle-bracket \
-- Space-after-end-angle-bracket \
-- One-true-brace-function-declaration \
-- Glue-amperscore \
-- Change-shell-comment-to-double-slashes-comment \
-- Force-large-php-code-tag \
-- Force-true-false-null-contant-lowercase \
-- Align-equal-statements \
-- Comment-rendering-style PEAR \
-- Equal-align-position 50 \
-- Padding-char-count 4 \
C: \ some \ path \ to \ file. php