我正在尝试使用vscode和php-debug extension调试php cli脚本,因此我在脚本中添加了一些断点并播放Launch currently open script
,但调试工具栏仅显示了一下并隐藏了。
这是launch.json配置
{
"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
}
]
}
配置xdebug日志后,我收到此消息
日志于2018-08-01 03:57:01打开I:连接到已配置 地址/端口:127.0.0.1:9000。 W:为“ 127.0.0.1:9000”创建套接字, 轮询成功,但错误:操作正在进行中(29)。 E:不能 连接到客户端。 :-(记录关闭于2018-08-01 03:57:01
我了解到此问题,建议更改端口
按照建议,我同时更改了20-xdebug.ini
和launch.json
文件中的xdebug端口,但是没有成功。我共享文件的内容
/etc/php/7.2/cli/conf.d/20-xdebug.ini
xdebug.show_error_trace = 1
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_handler=dbgp
xdebug.remote_port=9001
xdebug.remote_autostart=1
xdebug.remote_log=/var/log/xdebug.log
launch.json
{
"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": 9001
}
]
}
重新启动日志文件中的apache和vscode后,我收到此消息
Log opened at 2018-08-01 04:07:01
I: Connecting to configured address/port: 127.0.0.1:9001.
W: Creating socket for '127.0.0.1:9001', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-08-01 04:07:01
谢谢您的建议