我一直在尝试配置 sublime-phpcs。我已经安装了 pear 并从命令行安装了PHP_CodeSniffer和PHPMD使用他们记录的安装过程。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
我已经重新启动了服务器并在所有安装后重新打开了 sublimetext。
更新 响应 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
更新 2 响应 Sergey 的帮助,将 phpmd 可执行路径添加到用户设置中。
[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
有人有这个问题吗?