Is there a php code formatting tool in linux?

Source: Internet
Author: User
Tags php beautifier netbeans
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.