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