博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sublime Text2下安装php code sniffer插件
阅读量:4554 次
发布时间:2019-06-08

本文共 5642 字,大约阅读时间需要 18 分钟。

为了跟团队保持开发规范的一致性,需要安装sublime Text2的php code sniffer插件,之前是用的phpfmt插件,发现两个规范还是有点不一样,需要再安装php code sniffer.

参考网址: http://blog.chinaunix.net/uid-26374858-id-5039120.html

               http://fengzheng369.blog.163.com/blog/static/7522097920155342169

               https://github.com/squizlabs/sublime-PHP_CodeSniffer

 

安装步骤:

1) 下载php code sniffer (https://github.com/squizlabs/PHP_CodeSniffer)

  我用了下面的步骤安装:

cd /usr/local git clone git://github.com/squizlabs/PHP_CodeSniffer.gitcd PHP_CodeSnifferphp scripts/phpcs -hphp scripts/phpcbf -h

2)

brew install phpmd
sudo curl http://get.sensiolabs.org/php-cs-fixer.phar -o /usr/local/bin/php-cs-fixersudo chmod a+x /usr/local/bin/php-cs-fixer

 

3) 安装sublime phpcs插件

    安装方法(Ctrl+Shift+P->pi(package install)->phpcs,安装成功后右键即可看到PHP Code Sniffer选项).刚刚安装好的插件,sniff this file 显示的是灰色的,修改下配置文件(这是 Sublime 2的配置)

preferences->package settings->php code sniffer->setting-default

{    // Plugin settings    // Turn the debug output on/off    "show_debug": false,    // Which file types (file extensions), do you want the plugin to    // execute for    "extensions_to_execute": ["php"],    // Do we need to blacklist any sub extensions from extensions_to_execute    // An example would be ["twig.php"]    "extensions_to_blacklist": [],    // 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,    // The path to the php executable.    // Needed for windows, or anyone who doesn't/can't make phars    // executable. Avoid setting this if at all possible    "phpcs_php_prefix_path": "",    // Options include:    // - Sniffer    // - Fixer    // - Mess Detector    //    // This will prepend the application with the path to php    // Needed for windows, or anyone who doesn't/can't make phars    // executable. Avoid setting this if at all possible    "phpcs_commands_to_php_prefix": [],    // What color to stylise the icon    // https://www.sublimetext.com/docs/3/api_reference.html#sublime.View    // add_regsions    "phpcs_icon_scope_color": "comment",    // PHP_CodeSniffer settings    // Do you want to run the phpcs checker?    "phpcs_sniffer_run": true,    // Execute the sniffer on file save    "phpcs_command_on_save": true,    // It seems python/sublime cannot always find the phpcs application    // If empty, then use PATH version of phpcs, else use the set value    "phpcs_executable_path": "/usr/local/PHP_CodeSniffer/scripts/phpcs",    // Additional arguments you can specify into the application    //    // Example:    // {    //     "--standard": "PEAR",    //     "-n"    // }    "phpcs_additional_args": {        "--standard": "PSR2",        "-n": ""    },    // PHP-CS-Fixer settings    // Fix the issues on save    "php_cs_fixer_on_save": false,    // Show the quick panel    "php_cs_fixer_show_quick_panel": false,    // Path to where you have the php-cs-fixer installed    "php_cs_fixer_executable_path": "/usr/local/bin/php-cs-fixer",    // Additional arguments you can specify into the application    "php_cs_fixer_additional_args": {    },    // phpcbf settings    // Fix the issues on save    "phpcbf_on_save": true,    // Show the quick panel    "phpcbf_show_quick_panel": false,    // Path to where you have the phpcbf installed    "phpcbf_executable_path": "/usr/local/PHP_CodeSniffer/scripts/phpcbf",    // Additional arguments you can specify into the application    //    // Example:    // {    //     "--level": "all"    // }    "phpcbf_additional_args": {        "--standard": "PSR2",        "-n": ""    },    // PHP Linter settings    // Are we going to run php -l over the file?    "phpcs_linter_run": true,    // Execute the linter on file save    "phpcs_linter_command_on_save": true,    // It seems python/sublime cannot always find the php application    // If empty, then use PATH version of php, else use the set value    "phpcs_php_path": "/usr/local/PHP_CodeSniffer/scripts/phpcs",    // What is the regex for the linter? Has to provide a named match for 'message' and 'line'    "phpcs_linter_regex": "(?P
.*) on line (?P
\\d+)", // PHP Mess Detector settings // Execute phpmd "phpmd_run": false, // Execute the phpmd on file save "phpmd_command_on_save": true, // It seems python/sublime cannot always find the phpmd application // If empty, then use PATH version of phpmd, else use the set value "phpmd_executable_path": "", // Additional arguments you can specify into the application // // Example: // { // "codesize,unusedcode" // } "phpmd_additional_args": { "codesize,unusedcode,naming": "" }, // PHP Scheck settings // Execute scheck "scheck_run": false, // Execute the scheck on file save "scheck_command_on_save": false, // It seems python/sublime cannot always find the scheck application // If empty, then use PATH version of scheck, else use the set value "scheck_executable_path": "", // Additional arguments you can specify into the application // //Example: //{ // "-php_stdlib" : "/path/to/pfff", // "-strict" : "" //} "scheck_additional_args": { "-strict" : "" }}
  • ALT + S: Runs PHPCS command for the open buffer.
  • ALT + SHIFT + S: Runs PHPCBF command for the open buffer.

   

 

转载于:https://www.cnblogs.com/mingaixin/p/5342484.html

你可能感兴趣的文章
排序中文POJ 1696/hrbustoj 1318 几何 蛋疼的蚂蚁
查看>>
序数序列hdu 1394
查看>>
could not initialize proxy - no Session 问题分析
查看>>
Python数据类型Day02
查看>>
.NET Core WebAPI IIS 部署问题
查看>>
SystemTap 静态探针安装包
查看>>
minGW cygwin gnuwin32
查看>>
韩国 DBA 博客
查看>>
systemtap and postgrel
查看>>
RESTful levels & HATEOAS
查看>>
DEV 常用属性大全
查看>>
Spring的历史和哲学
查看>>
C# 字符串处理小工具
查看>>
研究显示云计算减少了管理安全性的时间和费用
查看>>
如何为您使用Windows Azure的应用程序评估成本
查看>>
初级排序算法之选择排序
查看>>
Spring Roo
查看>>
Hadoop and net core a match made in docker
查看>>
Javaweb项目构建常见问题
查看>>
SQLServer 错误: 15404,维护计划无法执行
查看>>