Vscode using Php-cs-fixer and PHP Formatter plug-ins to normalize PHP code

Source: Internet
Author: User
Tags coding standards php coding standards

What is Php-cs-fixer? It is the PHP code specification defined by Php-fig organization, good code specification can improve code readability, team communication maintenance costuse it to format your PHP code according to the specifications specified, which not only detects code that does not conform to the specification, but can also fix them

1. Format php files with Php-cs-fixer.phar     1.Download Php-cs-fixer.phar to any directory, try to put it in the PHP directory)    2. Manually call in VscodePhp-cs-fixer.pharto format2. In the VscodePHP Formatter Plugin1. Download Php-cs-fixer.phar to any directory, try to put it in the PHP directory)2. InstallationPHP Formatter Pluginand customize the settings (php path, Php-cs-fixer.phar Path, rules, etc.)3. Customizing PHP Formatter Plug -in shortcut keysThe configuration information is as follows:
Print log information for debugging "phpformatter.logging": true,//do not use composer way "Phpformatter.composer": false,//Add custom parameters, The default parameter level has been moved out of the new version so it will cause error//rules=[@PSR1, @PSR2, @Symfony]//source:https://github.com/friendsofphp/ Php-cs-fixer#usage "phpformatter.arguments": ["[Email protected]"],//should point-to-Php-cs-fixer.phar file, if you have Installed this manually (without Composer). should include. Phar extension.//Php-cs-fixer.phar Path, you can use composer mode without filling "phpformatter.pharpath": "d:/wamp/bin/php/ Php5.5.12/php-cs-fixer.phar ",//If The Pharpath is set, and you were not using Composer, and you haven ' t added PHP to your Path, this should point to the Php.exe file.//PHP path, you can use composer mode without filling "phpformatter.phppath": "d:/wamp/bin/php/ Php5.5.12/php.exe "

vscode customizing shortcut keys ConfigurationReference:php-cs-fixer: Formatting your PHP codeVscode-php-formatter Issuesuse Php-cs-fixer to automatically normalize your PHP codevscode Installing PHP formatting tools PHP FormatterGitHub Php-cs-fixerVscode plugin PHP FormatterPHP PSR-2 Code Style specification (Chinese version)-segmentfaultPSR-2: Coding Style Guidephp-cs-fixer (PHP Coding standards Fixer)



From Wiznote



Vscode using Php-cs-fixer and PHP Formatter plug-ins to normalize PHP code

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.