我正在尝试使用vscode调试php cli脚本和php-debug extension所以我在脚本中添加了一些断点并播放 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.inilaunch.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

谢谢你的任何建议