它是php-fig組織定義的PHP代碼規范,良好的代碼規范可以提高代碼可讀性,團隊溝通維護成本
使用它可以按照指定的規范格式化您的PHP代碼,此工具不僅可以檢測有不符合規范的代碼,而且還可以修復它們

1.使用php-cs-fixer.phar格式化php文件

2.在Vscode里
PHP Formatter 插件
3.自定義
PHP Formatter 插件的快捷鍵

配置信息如下:
//打印日志信息,用於調試 "phpformatter.logging":true, //不使用composer方式 "phpformatter.composer":false, //添加自定義參數,默認的參數level已經在新版本中移出所以會導致運行出錯 //RULES=[@PSR1,@PSR2,@Symfony] //source:https://github.com/FriendsOfPHP/PHP-CS-Fixer#usage "phpformatter.arguments":["--rules=@Symfony"], // Should point to php-cs-fixer.phar file, if you have installed this manually (without Composer). Should include .phar extension. // php-cs-fixer.phar路徑,使用composer方式時可以不填 "phpformatter.pharPath":"d:/wamp/bin/php/php5.5.12/php-cs-fixer.phar", // If the pharPath is set, and you are not using Composer, and you haven't added PHP to your PATH, this should point to the php.exe file. // php路徑,使用composer方式時可以不填 "phpformatter.phpPath":"d:/wamp/bin/php/php5.5.12/php.exe"
VScode自定義快捷鍵配置


參考: