首先按教程 http://blog.csdn.net/cyaspnet/article/details/51773331 装好phpcs和phpmd,需要先安装composer
composer global require "squizlabs/php_codesniffer=*"
安装后,在命令行输入 phpcs --version 显示版本号即为安装成功
如提示 shell_exec() has been disabled for security reasons ,请在 php.ini 禁用函数中 disable_functions 把 shell_exec 删除
composer global require phpmd/phpmd
安装后,在命令行输入 phpmd --version 显示版本号即为安装成功
然后在sublime 安装php code sniffer (网上教程说要去github下载其实是不需要的,sublime直接可以搜索到)
下面是我的配置
- {
-
-
-
-
-
- "show_debug": true,
-
-
- "extensions_to_execute": ["php"],
-
-
- "extensions_to_blacklist": ["twig.php"],
-
-
- "phpcs_execute_on_save": true,
-
-
- "phpcs_show_errors_on_save": true,
-
-
- "phpcs_show_gutter_marks": true,
-
-
- "phpcs_outline_for_errors": true,
-
-
- "phpcs_show_errors_in_status": true,
-
-
- "phpcs_show_quick_panel": true,
-
-
-
- "phpcs_php_prefix_path": "D:\\xampp\\php\\php.exe",
-
-
- "phpcs_commands_to_php_prefix": ["Fixer"],
-
-
-
-
- "phpcs_sniffer_run": true,
-
-
- "phpcs_command_on_save": true,
-
-
- "phpcs_executable_path": "D:\\xampp\\php\\phpcs.bat",
-
-
- "phpcs_additional_args": {
- "--standard": "PSR2",
- "-n": ""
- },
-
-
-
-
- "php_cs_fixer_on_save": false,
-
-
- "php_cs_fixer_show_quick_panel": true,
-
-
- "php_cs_fixer_executable_path": "D:\\xampp\\php\\php-cs-fixer.phar",
-
-
- "php_cs_fixer_additional_args": {
- },
-
-
-
-
- "phpcs_linter_run": true,
-
-
- "phpcs_linter_command_on_save": true,
-
-
- "phpcs_php_path": "D:\\xampp\\php\\php.exe",
-
-
- "phpcs_linter_regex": "(?P<message>.*) on line (?P<line>\\d+)",
-
-
-
-
- "phpmd_run": false,
- "phpmd_command_on_save": false,
- "phpmd_executable_path": "",
- "phpmd_additional_args": {
- "codesize,naming,unusedcode": ""
- },
-
- "phpcbf_executable_path": "D:\\xampp\\php\\phpcbf.bat"
- }
按这个配好了就可以用了, 顺便说下, 不要装phpfmt这个插件,这个是不符合规范的。