使用 VS Code 调试 php:无法附加到浏览器

我已经按照此处的说明安装了 xdebug:http://xdebug.org/wizard

https://img1.sycdn.imooc.com/6544b4bf0001da1509320733.jpg

我还安装了 Chrome 扩展调试器

https://img1.sycdn.imooc.com/6544b50400016a8005370287.jpg

现在我选择 index.php 文件并启动调试器,但出现以下错误:

https://img1.sycdn.imooc.com/6544b50d0001bce704050172.jpg

这是lunch.json的内容

https://img1.sycdn.imooc.com/6544b5170001b99806470295.jpg

这是我添加到 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. :-(


qq_笑_17
浏览 94回答 1
1回答

30秒到达战场

将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"        }    ]}
打开App,查看更多内容
随时随地看视频慕课网APP