Visual Studio Code (VSCode) - Error: Debug Adapter Process Has Terminated Unexpectedly
Visual Studio Code (VSCode) - Error: Debug Adapter Process Has Terminated Unexpectedly
我正在为这条错误消息而苦恼。有时我无法 运行 xdebug on Visual Studio 升级或重新启动编辑器后的代码。这是错误的屏幕截图:
谁能帮我解决这个问题?
经过几分钟了解我的机器上发生了什么,我弄清楚了如何解决我的问题。
因为 xdebug 是 运行 基于端口 9000
并且我在 Debug Console
(VSCode) 上看到消息 listen EADDRINUSE :::9000
,我认为端口 9000
上还有另一个进程 运行,所以我通过此命令
检查它上面的进程 运行
sudo netstat -nlp | grep :9000
上面的命令将显示端口 9000
上的进程 运行,然后我得到这个结果
tcp6 0 0 :::9000 :::* LISTEN 14856/hhvm
HHVM默认接管了xdebug的端口,所以我需要关闭它的服务或更改端口号。
提示:
您还可以使用lsof
查看特定端口上的进程
lsof -t -i :9000
我在开始使用 VSCode 时遇到了同样的问题。好吧,我花了 3 个小时才弄清楚到底是什么问题,我只是盯着一些逐步调试,比如正在使用的端口以及其他设置是什么。
最后我很幸运得到了解决方案:)所以我分享给大家。您可以检查我的发现是什么以及您需要设置什么才能使 Xdebug 与 VSCode.
一起工作
#VSCode & PHP调试
在 VS Code 中设置 Xdebug 以即时调试您的 PHP 代码。按照分步说明正确设置 xdebug。
Gif 动作:
如何使用 VSCode 设置 PHP 调试 (xdebug)?
1。 First of all Install VSCode
2。 Install PHP Debug Adapter for Visual Studio Code
3。 Install XDebug in WAMP
- 在浏览器中打开php信息
- 复制查看源码
- 粘贴到https://xdebug.org/wizard.php
- 下载建议的 xdebug dll 文件
- 将 dll 文件粘贴到当前版本的 php 文件夹 ext 或
zend_ext文件夹
- 打开phpinfo,找到'Loaded Configuration File'就知道了
php.ini 文件 wamp 使用
- 打开 php.ini 文件并将代码放在下方
[Xdebug] zend_extension="FULL-XDEBUG-DLL-FILE-PATH"
例子
;zend_extension="d:\wamp64\bin\php\php7.1.9\zend_ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"
或
;zend_extension="d:\wamp64\bin\php\php7.1.9\ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"
xdebug.remote_enable=1
xdebug.remote_autostart = 1
xdebug.remote_port="9000"
xdebug.profiler_enable=1
xdebug.remote_host="localhost"
xdebug.profiler_output_dir="<tmp path>"
;Example
;xdebug.profiler_output_dir="d:\wamp64\tmp"
4。重新启动 WAMP 服务器
Open phpinfo & find xdebug, If found then you have installed xdebug successfully!
If Wamp Restart But localhost not opening then try to change PORT. May PORT using by any other
application already.
How can you find out which process is listening on a port on Windows?
Setup XDebug in VSCode
Example JSON - launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
5。更新 VSCode PHP 设置以添加 PHP 可执行路径
"php.validate.run": "onType",
"php.validate.executablePath": "<Your-Full-PHP-Path>php.exe"
6。保存并重启VSCode
打开 PHP 项目文件夹并尝试调试代码。如果出现以下错误
VS Code Debug adapter process has terminated unexpectedly
或
VS Code Console Error -> listen EADDRINUSE::900)
这意味着 PORT 9000 当前正在被另一个程序使用,您可能有 运行 PHPStorm Xdebug 或任何其他使用 PORT 9000 的应用程序。尝试关闭PHPStorm 或其他程序并再次尝试调试。
仍然出现错误,然后尝试找到使用端口 9000 的程序并杀死它们。仍然出现错误尝试更改 php.ini 和 launch.json 中的端口并重新启动 wamp 和VSCode.
现在您可以看到 XDEBUG 在 VSCode 中工作。
> #### 要测试的示例代码
<?php
/*
|--------------------------------------------------------------------------
| PHP XDebug Code Example - VS Code
|--------------------------------------------------------------------------
|
| Information:
|
| VS Code :
| Version : 1.19.2
| Commit : 490ef761b76b3f3b3832eff7a588aac891e5fe80
| Date : 2018-01-10T15:55:03.538Z
| Shell : 1.7.9
| Renderer : 58.0.3029.110
| Node : 7.9.0
| Architecture : x64
|
| Windows : 10
|
| WAMP Server : 3.1.0
| PHP : 7.1.9
| APACHE : 2.4.27
| MySQL : 5.7.19
|
| PHP INI PATH : D:\wamp64\bin\apache\apache2.4.27\bin\php.ini
| [Xdebug]
| zend_extension = "d:\wamp64\bin\php\php7.1.9\zend_ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"
| xdebug.remote_enable = 1
| xdebug.remote_autostart = 1
| xdebug.remote_port = "9000"
| xdebug.profiler_enable = 1
| xdebug.remote_host = "localhost"
| xdebug.profiler_output_dir = "d:\wamp64\tmp"
|
*/
// first loop
for ($i=0; $i < 10; $i++) {
echo $i;
}
echo PHP_EOL;
// second loop
for ($i = 0; $i < 20; $i++)
{
echo $i;
}
/* End of file php-test.php */
/* Location: /wamp64/www/test/php-test.php */
谢谢:)
我在旧版本的 VS Code 上遇到了这个错误,我更新到 v1.37.1 并修复了它。
更新 VS Code 我遇到了 拒绝访问 错误,它提示我对话框 删除标记失败。我 运行 Process Monitor 并在对话框中单击 Retry,更新完成并工作。
我正在为这条错误消息而苦恼。有时我无法 运行 xdebug on Visual Studio 升级或重新启动编辑器后的代码。这是错误的屏幕截图:
谁能帮我解决这个问题?
经过几分钟了解我的机器上发生了什么,我弄清楚了如何解决我的问题。
因为 xdebug 是 运行 基于端口 9000
并且我在 Debug Console
(VSCode) 上看到消息 listen EADDRINUSE :::9000
,我认为端口 9000
上还有另一个进程 运行,所以我通过此命令
sudo netstat -nlp | grep :9000
上面的命令将显示端口 9000
上的进程 运行,然后我得到这个结果
tcp6 0 0 :::9000 :::* LISTEN 14856/hhvm
HHVM默认接管了xdebug的端口,所以我需要关闭它的服务或更改端口号。
提示:
您还可以使用lsof
查看特定端口上的进程
lsof -t -i :9000
我在开始使用 VSCode 时遇到了同样的问题。好吧,我花了 3 个小时才弄清楚到底是什么问题,我只是盯着一些逐步调试,比如正在使用的端口以及其他设置是什么。
最后我很幸运得到了解决方案:)所以我分享给大家。您可以检查我的发现是什么以及您需要设置什么才能使 Xdebug 与 VSCode.
一起工作#VSCode & PHP调试
在 VS Code 中设置 Xdebug 以即时调试您的 PHP 代码。按照分步说明正确设置 xdebug。
Gif 动作:
如何使用 VSCode 设置 PHP 调试 (xdebug)?
1。 First of all Install VSCode
2。 Install PHP Debug Adapter for Visual Studio Code
3。 Install XDebug in WAMP
- 在浏览器中打开php信息
- 复制查看源码
- 粘贴到https://xdebug.org/wizard.php
- 下载建议的 xdebug dll 文件
- 将 dll 文件粘贴到当前版本的 php 文件夹 ext 或 zend_ext文件夹
- 打开phpinfo,找到'Loaded Configuration File'就知道了 php.ini 文件 wamp 使用
- 打开 php.ini 文件并将代码放在下方
[Xdebug] zend_extension="FULL-XDEBUG-DLL-FILE-PATH"
例子
;zend_extension="d:\wamp64\bin\php\php7.1.9\zend_ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"
或
;zend_extension="d:\wamp64\bin\php\php7.1.9\ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"
xdebug.remote_enable=1
xdebug.remote_autostart = 1
xdebug.remote_port="9000"
xdebug.profiler_enable=1
xdebug.remote_host="localhost"
xdebug.profiler_output_dir="<tmp path>"
;Example
;xdebug.profiler_output_dir="d:\wamp64\tmp"
4。重新启动 WAMP 服务器
Open phpinfo & find xdebug, If found then you have installed xdebug successfully! If Wamp Restart But localhost not opening then try to change PORT. May PORT using by any other application already.
How can you find out which process is listening on a port on Windows?
Setup XDebug in VSCode
Example JSON - launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
5。更新 VSCode PHP 设置以添加 PHP 可执行路径
"php.validate.run": "onType",
"php.validate.executablePath": "<Your-Full-PHP-Path>php.exe"
6。保存并重启VSCode
打开 PHP 项目文件夹并尝试调试代码。如果出现以下错误
VS Code Debug adapter process has terminated unexpectedly
或
VS Code Console Error -> listen EADDRINUSE::900)
这意味着 PORT 9000 当前正在被另一个程序使用,您可能有 运行 PHPStorm Xdebug 或任何其他使用 PORT 9000 的应用程序。尝试关闭PHPStorm 或其他程序并再次尝试调试。
仍然出现错误,然后尝试找到使用端口 9000 的程序并杀死它们。仍然出现错误尝试更改 php.ini 和 launch.json 中的端口并重新启动 wamp 和VSCode.
现在您可以看到 XDEBUG 在 VSCode 中工作。
> #### 要测试的示例代码
<?php
/*
|--------------------------------------------------------------------------
| PHP XDebug Code Example - VS Code
|--------------------------------------------------------------------------
|
| Information:
|
| VS Code :
| Version : 1.19.2
| Commit : 490ef761b76b3f3b3832eff7a588aac891e5fe80
| Date : 2018-01-10T15:55:03.538Z
| Shell : 1.7.9
| Renderer : 58.0.3029.110
| Node : 7.9.0
| Architecture : x64
|
| Windows : 10
|
| WAMP Server : 3.1.0
| PHP : 7.1.9
| APACHE : 2.4.27
| MySQL : 5.7.19
|
| PHP INI PATH : D:\wamp64\bin\apache\apache2.4.27\bin\php.ini
| [Xdebug]
| zend_extension = "d:\wamp64\bin\php\php7.1.9\zend_ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"
| xdebug.remote_enable = 1
| xdebug.remote_autostart = 1
| xdebug.remote_port = "9000"
| xdebug.profiler_enable = 1
| xdebug.remote_host = "localhost"
| xdebug.profiler_output_dir = "d:\wamp64\tmp"
|
*/
// first loop
for ($i=0; $i < 10; $i++) {
echo $i;
}
echo PHP_EOL;
// second loop
for ($i = 0; $i < 20; $i++)
{
echo $i;
}
/* End of file php-test.php */
/* Location: /wamp64/www/test/php-test.php */
谢谢:)
我在旧版本的 VS Code 上遇到了这个错误,我更新到 v1.37.1 并修复了它。
更新 VS Code 我遇到了 拒绝访问 错误,它提示我对话框 删除标记失败。我 运行 Process Monitor 并在对话框中单击 Retry,更新完成并工作。