sublime安装PHPcs(PHPcodesniffer)代码规范提示插件
2017-08-02 11:17
691 查看
人生最痛苦的事莫过于在度娘寻找答案结果出来的是清一色的错误答案,本文的目的就是让大家正确的装好php code sniffer (格式检查和格式化)
首先按教程 http://blog.csdn.net/cyaspnet/article/details/51773331 装好phpcs和phpmd
然后在sublime 安装php code sniffer (网上教程说要去github下载其实是不需要的,sublime直接可以搜索到)
下面是我的配置
{
// Example for:
// - Windows 7
// - With phpcs and php-cs-fixer support
// We want debugging on
"show_debug": true,
// Only execute the plugin for php files
"extensions_to_execute": ["php"],
// Do not execute for twig files
"extensions_to_blacklist": ["twig.php"],
// Execute the sniffer on file save
"phpcs_execute_on_save": true,
// Show the error list after save.
"phpcs_show_errors_on_save": true,
// Show the errors in the gutter
"phpcs_show_gutter_marks": true,
// Show outline for errors
"phpcs_outline_for_errors": true,
// Show the errors in the status bar
"phpcs_show_errors_in_status": true,
// Show the errors in the quick panel so you can then goto line
"phpcs_show_quick_panel": true,
// Path to php on windows installation
// This is needed as we cannot run phars on windows, so we run it through php
"phpcs_php_prefix_path": "D:\\xampp\\php\\php.exe",
// We want the fixer to be run through the php application
"phpcs_commands_to_php_prefix": ["Fixer"],
// PHP_CodeSniffer settings
// Yes, run the phpcs command
"phpcs_sniffer_run": true,
// And execute it on save
"phpcs_command_on_save": true,
// This is the path to the bat file when we installed PHP_CodeSniffer
"phpcs_executable_path": "D:\\xampp\\php\\phpcs.bat",
// I want to run the PSR2 standard, and ignore warnings
"phpcs_additional_args": {
"--standard": "PSR2",
"-n": ""
},
// PHP-CS-Fixer settings
// Don't want to auto fix issue with php-cs-fixer
"php_cs_fixer_on_save": false,
// Show the quick panel
"php_cs_fixer_show_quick_panel": true,
// The fixer phar file is stored here:
"php_cs_fixer_executable_path": "D:\\xampp\\php\\php-cs-fixer.phar",
// Additional arguments, run all levels of fixing
"php_cs_fixer_additional_args": {
},
// PHP Linter settings
// Yes, lets lint the files
"phpcs_linter_run": true,
// And execute that on each file when saved (php only as per extensions_to_execute)
"phpcs_linter_command_on_save": true,
// Path to php
"phpcs_php_path": "D:\\xampp\\php\\php.exe",
// This is the regex format of the errors
"phpcs_linter_regex": "(?P<message>.*) on line (?P<line>\\d+)",
// PHP Mess Detector settings
// Not turning on the mess detector here
"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这个插件,这个是不符合规范的。
首先按教程 http://blog.csdn.net/cyaspnet/article/details/51773331 装好phpcs和phpmd
然后在sublime 安装php code sniffer (网上教程说要去github下载其实是不需要的,sublime直接可以搜索到)
下面是我的配置
{
// Example for:
// - Windows 7
// - With phpcs and php-cs-fixer support
// We want debugging on
"show_debug": true,
// Only execute the plugin for php files
"extensions_to_execute": ["php"],
// Do not execute for twig files
"extensions_to_blacklist": ["twig.php"],
// Execute the sniffer on file save
"phpcs_execute_on_save": true,
// Show the error list after save.
"phpcs_show_errors_on_save": true,
// Show the errors in the gutter
"phpcs_show_gutter_marks": true,
// Show outline for errors
"phpcs_outline_for_errors": true,
// Show the errors in the status bar
"phpcs_show_errors_in_status": true,
// Show the errors in the quick panel so you can then goto line
"phpcs_show_quick_panel": true,
// Path to php on windows installation
// This is needed as we cannot run phars on windows, so we run it through php
"phpcs_php_prefix_path": "D:\\xampp\\php\\php.exe",
// We want the fixer to be run through the php application
"phpcs_commands_to_php_prefix": ["Fixer"],
// PHP_CodeSniffer settings
// Yes, run the phpcs command
"phpcs_sniffer_run": true,
// And execute it on save
"phpcs_command_on_save": true,
// This is the path to the bat file when we installed PHP_CodeSniffer
"phpcs_executable_path": "D:\\xampp\\php\\phpcs.bat",
// I want to run the PSR2 standard, and ignore warnings
"phpcs_additional_args": {
"--standard": "PSR2",
"-n": ""
},
// PHP-CS-Fixer settings
// Don't want to auto fix issue with php-cs-fixer
"php_cs_fixer_on_save": false,
// Show the quick panel
"php_cs_fixer_show_quick_panel": true,
// The fixer phar file is stored here:
"php_cs_fixer_executable_path": "D:\\xampp\\php\\php-cs-fixer.phar",
// Additional arguments, run all levels of fixing
"php_cs_fixer_additional_args": {
},
// PHP Linter settings
// Yes, lets lint the files
"phpcs_linter_run": true,
// And execute that on each file when saved (php only as per extensions_to_execute)
"phpcs_linter_command_on_save": true,
// Path to php
"phpcs_php_path": "D:\\xampp\\php\\php.exe",
// This is the regex format of the errors
"phpcs_linter_regex": "(?P<message>.*) on line (?P<line>\\d+)",
// PHP Mess Detector settings
// Not turning on the mess detector here
"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这个插件,这个是不符合规范的。
相关文章推荐
- 2016 正确 sublime安装PHPcs PHPcodesniffer代码规范提示插件,修正网上部分不详细描述
- Sublime安装php代码提示插件
- 规范PHP代码-git hook中安装phpcs
- myeclipse中eclipse PHP插件的安装及代码自动提示配置
- Sublime代码规范安装实时监测插件安装
- 【sublime】sublime Text 3 javaScript代码自动提示插件&安装步骤 &启动Debug模式
- sublime代码提示安装插件过程
- 【sublime】sublime Text 3 javaScript代码自动提示插件&安装步骤 &启动Debug模式
- PHP代码规范与质量检查工具PHPCS,PHPMD的安装与配置
- IDE-Sublime【2】-代码智能提示插件SublimeCodeIntel的安装
- Zend Studio 上 安装使用Aptana插件(html,css,js代码提示功能) .
- 使用 PHP_CodeSniffer 检查 代码 是否 符合 编码规范
- MyEclipse 2015实现JavaScript代码自动提示(不需要额外安装插件)
- 仿百度搜索输入框提示JS代码(PHP+MySql数据库版)(基于jquery.autocomplete.js插件)
- sublime test3 安装quick-cocos2d-x 代码补全插件
- Aptana中安装ExtJS 代码提示插件
- Android Studio自动检查代码规范并提示如何优化的一些插件
- WebStorm 最新 2016 AngularJs 2 代码提示插件安装
- Sublime Text 3 PHP代码格式化插件phpfmt的安装和配置
- MyEclipse安装JS代码提示插件——Spket插件)