Home Backend Development PHP Tutorial PHP code beautification tool-phpCodeBeautifier[integrated in EditPlus]_PHP tutorial

PHP code beautification tool-phpCodeBeautifier[integrated in EditPlus]_PHP tutorial

Jul 13, 2016 pm 05:54 PM
editplus php for code use exist tool beautify integrated

Add PHP code beautification tool to EditPlus using PHPCB

PHP code formatting tool that can be integrated in EditPlus or other editors: phpCodeBeautifier, referred to as phpCB.
It can beautify the PHP code format and make the chaotic PHP code neat.


After installing EditPlusr, in the menu bar, there is a menu of [Tools (T)] -> [Configure User Tools]. After opening it, we click [User Tools] ->[Add Tool] -> [Application 】.
The menu text reads: PHP code beautification; command: select the local save address of phpCB.
Write parameters: $(FilePath) or the following content (the command is one line), please refer to the phpCodeBeautifier User Manual for details.
--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 filling: $(FileDir)
Finally, pay attention to the selection: "Run text filtering" and select "Replace" in the drop-down box,

PHP code beautification tool-phpCodeBeautifier[integrated in EditPlus]_PHP tutorial

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,
Then the program will automatically organize our messy code, making our code more beautiful and easier 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 bla';

$showBlaBlaBlaMessage = false;

?>
$noError               = true;
$feildEmpty            = false;
$showMessage           = false;
$showMessage           = false;
$anotherVariable[0123] = 'bla 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 bla';

$showBlaBlaBlaMessage = false;

?>
$noError                     = true;
$feildEmpty                  = false;
$showMessage                 = false;
$showMessage                 = false;
$anotherVariable[0123]       = 'bla bla bla';
$showBlaBlaBlaMessage        = false;

?>

 

Comment rendering style
The following style of comment formating are available:

--comment-rendering-style PEAR --comment-rendering-style PHPDoc

/**
 * bla bla bla
 *
 * @access public
 */

?>

/**
* bla bla 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:somepathtofile.php
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477960.htmlTechArticle使用PHPCB为EditPlus添加PHP代码美化工具 可以集成在EditPlus或其它编辑器中的PHP代码格式化工具:phpCodeBeautifier,简称phpCB。 它能够美化PHP代码...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Ouyi Ouyi Ouyi Ouix Ouyi Global Station Login Home Page Ouyi Ouyi Ouyi Ouix Ouyi Global Station Login Home Page Apr 21, 2025 pm 11:57 PM

Ouyi OKX is the world's leading digital asset trading platform. 1) Its development history includes: it will be launched in 2017, the Chinese name "Ouyi" will be launched in 2021, and it will be renamed Ouyi OKX in 2022. 2) Core services include: trading services (coin, leverage, contracts, DEX, fiat currency trading) and financial services (Yubibao, DeFi mining, lending). 3) The platform's special functions include: market data services and risk control system. 4) Core advantages include: technical strength, security system, service support and market coverage.

Recommended essential software for currency contract parties Recommended essential software for currency contract parties Apr 21, 2025 pm 11:21 PM

The top ten cryptocurrency contract exchange platforms in 2025 are: 1. Binance Futures, 2. OKX Futures, 3. Gate.io, 4. Huobi Futures, 5. BitMEX, 6. Bybit, 7. Deribit, 8. Bitfinex, 9. CoinFLEX, 10. Phemex, these platforms are widely recognized for their high liquidity, diversified trading functions and strict security measures.

Ranking of leveraged exchanges in the currency circle The latest recommendations of the top ten leveraged exchanges in the currency circle Ranking of leveraged exchanges in the currency circle The latest recommendations of the top ten leveraged exchanges in the currency circle Apr 21, 2025 pm 11:24 PM

The platforms that have outstanding performance in leveraged trading, security and user experience in 2025 are: 1. OKX, suitable for high-frequency traders, providing up to 100 times leverage; 2. Binance, suitable for multi-currency traders around the world, providing 125 times high leverage; 3. Gate.io, suitable for professional derivatives players, providing 100 times leverage; 4. Bitget, suitable for novices and social traders, providing up to 100 times leverage; 5. Kraken, suitable for steady investors, providing 5 times leverage; 6. Bybit, suitable for altcoin explorers, providing 20 times leverage; 7. KuCoin, suitable for low-cost traders, providing 10 times leverage; 8. Bitfinex, suitable for senior play

What are the hybrid blockchain trading platforms? What are the hybrid blockchain trading platforms? Apr 21, 2025 pm 11:36 PM

Suggestions for choosing a cryptocurrency exchange: 1. For liquidity requirements, priority is Binance, Gate.io or OKX, because of its order depth and strong volatility resistance. 2. Compliance and security, Coinbase, Kraken and Gemini have strict regulatory endorsement. 3. Innovative functions, KuCoin's soft staking and Bybit's derivative design are suitable for advanced users.

Recommend several apps to buy mainstream coins in 2025 latest release Recommend several apps to buy mainstream coins in 2025 latest release Apr 21, 2025 pm 11:54 PM

APP software that can purchase mainstream coins includes: 1. Binance, the world's leading, large transaction volume and fast speed; 2. OKX, innovative products, low fees, high security; 3. Gate.io, a variety of assets and trading options, focusing on security; 4. Huobi (HTX), low fees, good user experience; 5. Coinbase, suitable for novices, high security; 6. Kraken, safe and compliant, providing a variety of services; 7. KuCoin, low fees, suitable for professional traders; 8. Gemini, emphasizes compliance, and provides custodial services; 9. Crypto.com, providing a variety of offers and services; 10. Bitstamp, an old exchange, strong liquidity,

Which Bitcoin futures exchange is global? Which Bitcoin futures exchange is global? Apr 21, 2025 pm 11:18 PM

The top five Bitcoin futures exchanges rankings are: 1. CME Group: The most trustworthy in the world, attracting institutional investors, and have strong compliance; 2. Coinbase: Specially for retail investors, providing 13 futures contracts, with high ease of use; 3. Binance: High leverage, good liquidity, and large user volume; 4. OKX: Large cumulative trading volume, professional interface, and complete risk management; 5. Kraken: High security, suitable for European market and institutional customers.

Ethereum cross-chain trading app_What are the Ethereum cross-chain trading software? Ethereum cross-chain trading app_What are the Ethereum cross-chain trading software? Apr 21, 2025 pm 10:54 PM

APPs or software that support cross-chain transactions on Ethereum include: 1. XBIT, which supports 8 mainstream public chains and zero Gas fee transactions; 2. Binance, which supports extensive blockchain networks and 0 Gas fee transfers; 3. TokenPocket, which supports multi-chain transactions and management; 4. AnySwap, which supports multi-chain asset exchange; 5. THORSwap, which supports over 4,800 ERC-20 Token redemption.

What are the quantum chain trading platforms? What are the quantum chain trading platforms? Apr 21, 2025 pm 11:45 PM

Platforms that support Qtum trading are: 1. Binance, 2. OKX Ouyi, 3. Huobi, 4. Gate.io Sesame Open Door, 5. Siren, 6. Coinku, 7. Bit stamp, 8. Coinku, 9. Bybit, 10. Gemini, these platforms have their own characteristics and advantages.

See all articles