Xdebug触发异常但不触发断点

时间:2019-05-20 07:36:52

标签: php xdebug

问题

我目前正在忙于使用VSCode用PHP开发网站。我想在网站上进行远程调试,因此我在服务器上安装了Xdebug,在VS Code上安装了PHP Debug。

我从Xdebug日志中看到它已成功连接到我的机器,但是随后停止了。但是,如果我的代码抛出异常,它将立即在VS Code中中断而不会出现问题。所以我不是100%知道为什么它可以处理异常但不能处理断点

我尝试删除并重置所有断点,重新启动apache,打开防火墙上的端口,尝试重新启动PC。但是都无济于事。

我不太确定为什么在VS Code中触发并触发了异常,但断点却没有。感谢您的反馈!


日志和配置

我的虚拟主机配置具有激活Xdebug的行:

php_flag xdebug.remote_enable on

我的Xdebug配置为:

zend_extension = /usr/lib/php/20160303/xdebug.so
xdebug.show_error_trace=1
xdebug.remote_autostart = 1
xdebug.remote_enable = 0
xdebug.remote_handler = dbgp
xdebug.remote_host = 197.159.61.250
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000

我的VSCode launch.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",
            "pathMappings": {
                "/var/www/portal.***.co.za": "D:/Projects/Work/***/*** Source/"
            },
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

Xdebug的日志:

[20180] Log opened at 2019-05-20 07:21:57
[20180] I: Connecting to configured address/port: 197.***.**.***:9000.
[20180] I: Connected to client. :-)
[20180] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/portal.***s.co.za/pages/user/reports/eventRaceReport.php" language="PHP" xdebug:language_version="7.1.27-1+ubuntu16.04.1+deb.sury.org+1" protocol_version="1.0" appid="20180"><engine version="2.7.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init>
[20180]
[20180] <- breakpoint_list -i 1
[20180] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>
[20180]
[20180] <- breakpoint_set -i 2 -t line -f d:/Projects/Work/***/***%20Source/pages/user/reports/eventRaceReport.php -n 167
[20180] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="201800001"></response>
[20180]
[20180] <- breakpoint_list -i 3
[20180] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"><breakpoint type="line" filename="file:///d:/Projects/Work/***/***%2520Source/pages/user/reports/eventRaceReport.php" lineno="167" state="enabled" hit_count="0" hit_value="0" id="201800001"></breakpoint></response>
[20180]
[20180] <- breakpoint_list -i 4
[20180] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"><breakpoint type="line" filename="file:///d:/Projects/Work/***/***%2520Source/pages/user/reports/eventRaceReport.php" lineno="167" state="enabled" hit_count="0" hit_value="0" id="201800001"></breakpoint></response>
[20180]
[20180] <- breakpoint_set -i 5 -t exception -x *
[20180] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="201800002"></response>
[20180]
[20180] <- run -i 6
[20180] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="6" status="stopping" reason="ok"></response>
[20180]
[20180] <- stop -i 7
[20180] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="7" status="stopped" reason="ok"></response>
[20180]
[20180] Log closed at 2019-05-20 07:22:02

0 个答案:

没有答案