Sublime Text 3的PHPCS插件给出了WinError 2

时间:2013-09-20 15:45:44

标签: php sublimetext3

我为Sublime Text 3安装了PHPCS插件,并按如下方式设置用户配置文件:

{

// 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": "C:\\wamp\bin\\php\\php5.4.12\\php.exe",

// This is the path to the bat file when we installed PHP_CodeSniffer
"phpcs_executable_path": "C:\\wamp\\bin\\php\\php5.4.12\\phpcs.bat",

// 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": "C:\\wamp\bin\\php\\php5.4.12\\php-cs-fixer.phar",

// 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": "C:\\wamp\bin\\php\\php5.4.12\\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": {}
}

当我尝试嗅探PHP文件时,我收到以下错误: “FileNotFoundError:[WinError 2]系统找不到指定的文件”

我已经仔细检查了我的路径并且它们是正确的,是否可能Sublime只读取默认配置文件而不是用户配置文件?

编辑 - 我的路径错过了第二次反斜杠,我道歉,嗅探器现在正在工作。

1 个答案:

答案 0 :(得分:4)

我试过没有阅读任何说明,我找到了解决方案。尝试以下步骤:

  • 通过ST3中的Package Control下载php code sniffer addon。
  • 从此网站下载php-cs-fixer文件=&gt; cs.sensiolabs.org/(直接链接=&gt; cs.sensiolabs.org/get/php-cs-fixer.phar)
  • 将下载的文件复制到您的php.exe目录(我的是 C:/XAMMP/php/php.exe)
  • 从此页面下载PHP_CodeSniffer PEAR代码包pear.php.net/package/PHP_CodeSniffer/download/All(Direct Link =&gt; http://download.pear.php.net/package/PHP_CodeSniffer-1.5.0RC4.tgz
  • 找到 PHP_CodeSniffer-1.5.0RC4.tgz \ PHP_CodeSniffer-1.5.0RC4 \脚本\ phpcs.bat 并复制此文件(在您的php.exe目录中)
  • 复制第一篇文章的配置文件,在写入时相应地更改目录 包装设置 - &gt; Php Code Sniffer - &gt;设置 - 用户文件。 这个方法为我工作在Win8 x64系统上的Sublime Text 3 Build 3047 ...对我来说没有更慢的ST2 ...... 干杯