dan*_*yag 2 php xdebug visual-studio-code
我正在尝试使用 VSCode(VSCcode 版本 1.9.1)配置 xdebug。
配置文件
[Xdebug]
zend_extension = D:\php\ext\php_xdebug.dll
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_log = D:\site\xlog.txt
Run Code Online (Sandbox Code Playgroud)
我默认的PHP端口是3000,($_SERVER['SERVER_PORT'] = 3000
其实我可以运行phpinfo()在localhost:3000
和Xdebug端口设置为xdebug.remote_port = 9000
X调试日志:
Log opened at 2017-02-17 20:50:56
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///D:/site/index.php" language="PHP" xdebug:language_version="7.1.0-dev" protocol_version="1.0" appid="11384" idekey="Admin"><engine version="2.5.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>
<- breakpoint_list -i 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>
<- breakpoint_list -i 2
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="2"></response>
<- breakpoint_set -i 3 -t exception -x *
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="113840001"></response>
<- run -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="4" status="stopping" reason="ok"></response>
<- stop -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stop" transaction_id="5" status="stopped" reason="ok"></response>
Log closed at 2017-02-17 20:50:56
Run Code Online (Sandbox Code Playgroud)
启动.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
}
]
}
Run Code Online (Sandbox Code Playgroud)
对于以下测试代码:
$var = "test\n";
print $var;
var_dump($var);
Run Code Online (Sandbox Code Playgroud)
我在调试控制台中得到了这个:
test D:\site\index.php:5: string(5) "test "
Run Code Online (Sandbox Code Playgroud)
但是调试列表中没有变量..
我不知道为什么,但变量没有出现在 VSCode 中。
当我尝试到达时localhost:3000......这是我得到的:
Log opened at 2017-02-17 21:38:16
I: Connecting to configured address/port: localhost:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-02-17 21:38:17
Run Code Online (Sandbox Code Playgroud)
小智 6
我有一个类似的问题 - 您提供的相同日志条目,相同的症状,几乎相同的配置。XDebug 上周突然对我失败了,所有局部变量开始显示为“未定义”,没有弹出检查等。在我拥有的另一台几乎相同的主机上调试相同的代码继续工作得很好。
在卸载并重新安装 XDebug 和多次涉及的 VSCode 扩展并尝试了许多配置更改后,我最终发现问题是由我放在监视列表中的表达式引起的。一旦有问题的表达式从我的监视列表中删除(它以某种方式在所有卸载/重新安装周期中幸存下来)XDebug 立即开始再次正常工作。
监视列表表达式可能导致整个 XDebug 堆栈卷曲并死亡,这有点蹩脚,但确实如此。认为这种经验值得分享,因为其他人将来无疑会遇到类似的问题,并最终在这里寻找答案。
| 归档时间: |
|
| 查看次数: |
5879 次 |
| 最近记录: |