I've been trying to configure sublime-phpcs. I've installed pear and from command line installed PHP_CodeSniffer, and PHPMD using their documented install procedures. PHP and pear are in my path at d:/Program Files/xampp/php and d:/Program Files/xampp/php/pear, and I can use them outside of the directories. I set PHPCodeSniffer, PHPMD, and showdebug to be true in the user config file, but on save nothing get highlighted or outlined, can only see an error in the console. It pops an error after saying:
[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
I've restarted the server and reopened sublimetext after all installs.
UPDATE In response to Sergey's help with the addition of the phpcs executable path to user settings.
[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
UPDATE 2 In response to Sergey's help with the addition of the phpmd executable path to user settings.
[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
Anyone had this issue?
Try to open PHPCS settings: Preferences → Package Settings → PHP Code Sniffer → Settings — User
Add this to the settings file:
{
"phpcs_executable_path": "some_path"
}
Where some_path
is the phpcs's executable path (if you have installed it by PEAR command in Windows, its executable file is phpcs.bat
in root folder of PHP). :)
For example, I have installed code sniffer and its executable is D:\dev\php\phpcs.bat
. So my config is
{
"phpcs_executable_path": "D:\\dev\\php\\phpcs.bat",
// Enable debug to see verbose output
"show_debug": true
}
Sublime-phpcs did not work for me, too, until I've set phpcs_executable_path
in its config.
Update: As I see from your question update, right now you need also set phpmd_executable_path
. Also I will use your path to PHP in this listing.
{
"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
}