崇高的phpcs-Can';不要让PHP MD和CS包正常运行

崇高的phpcs-Can';不要让PHP MD和CS包正常运行,php,pear,sublimetext3,codesniffer,phpmd,Php,Pear,Sublimetext3,Codesniffer,Phpmd,我一直在尝试配置Supreme PHPC。我已经安装了pear和from命令行安装,并使用了它们的文档化安装过程。PHP和pear在我的路径中,分别位于d:/Program Files/xampp/PHP和d:/Program Files/xampp/PHP/pear,我可以在目录之外使用它们。我在用户配置文件中将PHPCodeSniffer、PHPMD和showdebug设置为true,但在保存时,不会突出显示或概述任何内容,只能在控制台中看到错误。它会在说了以下内容后弹出一个错误: [Php

我一直在尝试配置Supreme PHPC。我已经安装了pear和from命令行安装,并使用了它们的文档化安装过程。PHP和pear在我的路径中,分别位于d:/Program Files/xampp/PHP和d:/Program Files/xampp/PHP/pear,我可以在目录之外使用它们。我在用户配置文件中将PHPCodeSniffer、PHPMD和showdebug设置为true,但在保存时,不会突出显示或概述任何内容,只能在控制台中看到错误。它会在说了以下内容后弹出一个错误:

[Phpcs] phpcs --report=checkstyle --standard=PSR2 -n D:\htdocs\ubc\app\main\source\plugins\project\core\class-cse-meta-boxes.php
[Phpcs] phpcs --report=checkstyle --standard=PSR2 -n D:\htdocs\ubc\app\main\source\plugins\project\core\class-cse-meta-boxes.php
[Phpcs] cwd: C:\Users\mtpultz
Exception in thread Thread-183:
Traceback (most recent call last):
File "X/subprocess.py", line 1090, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "X/threading.py", line 639, in _bootstrap_inner
File "X/threading.py", line 596, in run
File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 433, in run
File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 139, in get_errors
File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 215, in execute
File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 218, in parse_report
File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 169, in shell_out
File "X/subprocess.py", line 818, in __init__
File "X/subprocess.py", line 1096, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
我已重新启动服务器,并在所有安装之后重新打开SublimiteText

更新 响应Sergey的帮助,将phpcs可执行路径添加到用户设置中

[Phpcs] phpmd D:\htdocs\ubc\app\main\source\plugins\ubc\core\class-cse-meta-boxes.php text codesize,unusedcode,naming
[Phpcs] phpmd D:\htdocs\ubc\app\main\source\plugins\ubc\core\class-cse-meta-boxes.php text codesize,unusedcode,naming
[Phpcs] cwd: C:\Users\mtpultz
Exception in thread Thread-183:
Traceback (most recent call last):
  File "X/subprocess.py", line 1090, in _execute_child
  FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "X/threading.py", line 596, in run
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 435, in run
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 139, in get_errors
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 311, in execute
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 314, in parse_report
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 169, in shell_out
  File "X/subprocess.py", line 818, in __init__
  File "X/subprocess.py", line 1096, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
[Phpcs] D:\Program Files\xampp\php\pear\phing\tasks\ext\phpmd D:\htdocs\ubc\app\main\source\plugins\ubc-petrography\core\class-cse-meta-boxes.php text codesize,unusedcode,naming
[Phpcs] D:\Program Files\xampp\php\pear\phing\tasks\ext\phpmd D:\htdocs\ubc\app\main\source\plugins\ubc-petrography\core\class-cse-meta-boxes.php text codesize,unusedcode,naming
[Phpcs] cwd: C:\Users\mtpultz
Exception in thread Thread-18:
Traceback (most recent call last):
  File "X/subprocess.py", line 1090, in _execute_child
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "X/threading.py", line 596, in run
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 435, in run
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 139, in get_errors
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 311, in execute
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 314, in parse_report
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 169, in shell_out
  File "X/subprocess.py", line 818, in __init__
  File "X/subprocess.py", line 1096, in _execute_child
PermissionError: [WinError 5] Access is denied
更新2 响应Sergey的帮助,将phpmd可执行路径添加到用户设置中

[Phpcs] phpmd D:\htdocs\ubc\app\main\source\plugins\ubc\core\class-cse-meta-boxes.php text codesize,unusedcode,naming
[Phpcs] phpmd D:\htdocs\ubc\app\main\source\plugins\ubc\core\class-cse-meta-boxes.php text codesize,unusedcode,naming
[Phpcs] cwd: C:\Users\mtpultz
Exception in thread Thread-183:
Traceback (most recent call last):
  File "X/subprocess.py", line 1090, in _execute_child
  FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "X/threading.py", line 596, in run
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 435, in run
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 139, in get_errors
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 311, in execute
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 314, in parse_report
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 169, in shell_out
  File "X/subprocess.py", line 818, in __init__
  File "X/subprocess.py", line 1096, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
[Phpcs] D:\Program Files\xampp\php\pear\phing\tasks\ext\phpmd D:\htdocs\ubc\app\main\source\plugins\ubc-petrography\core\class-cse-meta-boxes.php text codesize,unusedcode,naming
[Phpcs] D:\Program Files\xampp\php\pear\phing\tasks\ext\phpmd D:\htdocs\ubc\app\main\source\plugins\ubc-petrography\core\class-cse-meta-boxes.php text codesize,unusedcode,naming
[Phpcs] cwd: C:\Users\mtpultz
Exception in thread Thread-18:
Traceback (most recent call last):
  File "X/subprocess.py", line 1090, in _execute_child
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "X/threading.py", line 596, in run
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 435, in run
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 139, in get_errors
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 311, in execute
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 314, in parse_report
  File "phpcs in C:\Users\mtpultz\AppData\Roaming\Sublime Text 3\Installed Packages\Phpcs.sublime-package", line 169, in shell_out
  File "X/subprocess.py", line 818, in __init__
  File "X/subprocess.py", line 1096, in _execute_child
PermissionError: [WinError 5] Access is denied

有人遇到此问题吗?

尝试打开PHPCS设置:首选项→ 包设置→ PHP代码嗅探器→ 设置-用户

将其添加到设置文件:

{
    "phpcs_executable_path": "some_path"
}
其中
some_path
是phpcs的可执行路径(如果您在Windows中通过PEAR命令安装了它,它的可执行文件是PHP根文件夹中的
phpcs.bat
):)

例如,我安装了代码嗅探器,它的可执行文件是
D:\dev\php\phpcs.bat
。所以我的配置是

{
    "phpcs_executable_path": "D:\\dev\\php\\phpcs.bat",
    // Enable debug to see verbose output
    "show_debug": true
}
直到我在配置中设置了
phpcs\u executable\u path
,崇高的phpcs才对我起作用

更新:正如我从您的问题更新中所看到的,现在您还需要设置
phpmd\u可执行文件路径
。在这个清单中,我还将使用您的PHP路径

{
    "phpcs_executable_path": "D:\\Program Files\\xampp\\php\\phpcs.bat",
    "phpmd_executable_path": "D:\\Program Files\\xampp\\php\\phpmd.bat",
    // Enable debug to see verbose output
    "show_debug": true
}

您好,我将phpcs_可执行文件_路径更改为“D:\\Program Files\\xampp\\php\\phpcs.bat”,如您所述,我还注意到默认设置中的phpcs_php_路径,并在用户设置中添加了D:\\Program Files\\xampp\\php。就我而言,这绝对是一个过度的站点,但我仍然收到相同的错误,并且没有php错误通知。@mtpultz让我们只从添加
phpcs\u可执行路径开始,没有任何其他内容,没有
phpcs\u php\u路径
?哦,不。我们还需要添加
“show_debug”:true
。我已经更新了我的代码列表。看上面。嗨,好的,我已经做了,一个空白错误列表现在显示在sublime控制台中。编辑器中没有行指示器或高亮显示,底部的错误消息已更改。我已经编辑了问题以反映更改。我猜这意味着要添加到phpmd的路径吗?但我实际上找不到pear在哪里安装了它。@mtpultz我在我的答案中添加了另一个清单。请参阅“更新”部分。