Find a formatting tool for php code in linux and a formatting tool for php code in linux.
Reply content:
A formatting tool for php code in linux
1. You can use vim for linux debugging.
"Do not use spaces to replace the tab set expandtab" Use the tab set smarttab at the beginning of the line and segment "and indent it to 4 set shiftwidth = 4 set tabstop = 4 set softtabstop = 4" To set automatic contraction set autoindent "cindent's indentation of c syntax is more intelligent and flexible set cindent" slightly more intelligent than autoindent's automatic indent, in this indent mode, set pasteset smartindent is used when each line has the same indentation as the previous line.
Command: gg = G
2. format the entire directory using PHP-CS-Fixer for composer-managed
php php-cs-fixer.phar fix /path/to/dirphp php-cs-fixer.phar fix /path/to/filephp php-cs-fixer.phar fix /path/to/project --level=psr0php php-cs-fixer.phar fix /path/to/project --level=psr1php php-cs-fixer.phar fix /path/to/project --level=psr2php php-cs-fixer.phar fix /path/to/project --level=symfony
The format can be automatically formatted according to the PSR standard.
3. format the entire directory using PHP Beautifier
This is a pear class library.
pear install php_beautifier-0.1.15
But this is a bit old.
4. Other IDE and coding
PHPStorm, Netbeans, and Subline can all be formatted.
Recommended Methods
1. Use an editor that can be formatted for individual files
2. Use PHP-CS-Fixer as a whole
Command Line?
Vim can
Omnipotent vim
Try this, online
Http://web.chacuo.net/formatphp
However, you need to manually upload files one by one in netbeans. Or write a script by yourself?
PHP_Beautifer
Install PHPStorm, open the file, press Ctrl + A to select all, and press Ctrl + Alt + L to reformat, over ~
B. t. w. Do you all use IDE?
After Adobe Brackets is installed with the beauets extension, press Ctrl + Shift + L to format the selected code. The right-click menu also provides Beautify formatting. IDE like Netbeans for PHP also supports code formatting.
Of course, it is vim, gg = G. Of course, you must configure it first.