使用 VS 代码调试 php:无法附加到浏览器
Debug php using VS Code: Unable to attach to browser
我已经按照这里的说明安装了 xdebug:http://xdebug.org/wizard
我还为 Chrome 扩展安装了调试器
现在我选择 index.php 文件并启动调试器,但出现以下错误:
这是lunch.json
的内容
这是我添加到 php.ini
的配置
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
zend_extension = /usr/lib/php/20170718/xdebug.so
更新:
我已将 xdebug.remote_log=/tmp/xdebug.log
添加到 php.ini,这是我得到的错误:
[3569] I: Connecting to configured address/port: localhost:9000.
[3569] W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (29).
[3569] E: Could not connect to client. :-(
我关注了@Derick 在评论中提供的this document。我将 lunch.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,
"runtimeExecutable": "/usr/bin/php.exe"
}
]
}
我已经按照这里的说明安装了 xdebug:http://xdebug.org/wizard
我还为 Chrome 扩展安装了调试器
现在我选择 index.php 文件并启动调试器,但出现以下错误:
这是lunch.json
的内容这是我添加到 php.ini
的配置xdebug.remote_enable = 1
xdebug.remote_autostart = 1
zend_extension = /usr/lib/php/20170718/xdebug.so
更新:
我已将 xdebug.remote_log=/tmp/xdebug.log
添加到 php.ini,这是我得到的错误:
[3569] I: Connecting to configured address/port: localhost:9000.
[3569] W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (29).
[3569] E: Could not connect to client. :-(
我关注了@Derick 在评论中提供的this document。我将 lunch.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,
"runtimeExecutable": "/usr/bin/php.exe"
}
]
}