问题
I have Xdebug 2.1 installed, and running with PHP 5.2.13. It can successfully connect to multiple DBGP clients (i.e. the xdebug.remote_log
shows communication back and forth, and the clients themselves also show the incoming connection), but it doesn't stop at breakpoints. I have tried NetBeans, MacGDBp and also the command-line debugclient bundled with Xdebug.
A typical exchange looks like:
Log opened at 2010-07-20 09:33:17
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///mnt/hgfs/htdocs/mycompany/index.php" language="PHP" protocol_version="1.0" appid="14371" idekey="macgdbp"><engine version="2.1.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2010 by Derick Rethans]]></copyright></init>
<- status -i macgdbp
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="macgdbp" status="starting" reason="ok"></response>
<- step_into -i macgdbp
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="macgdbp" status="stopping" reason="ok"></response>
<- status -i macgdbp
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="macgdbp" status="stopping" reason="ok"></response>
Log closed at 2010-07-20 09:33:18
NetBeans attempts to set breakpoints, and these are acknowledged by Xdebug:
<- breakpoint_set -i 7 -t line -s enabled -f file:///mnt/hgfs/htdocs/mycompany/index.php -n 9
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" state="enabled" id="139360004"></response>
However, Xdebug still refuses to stop!
回答1:
This appears to happen if you have have Xdebug loaded as an extension
(i.e. extension=xdebug.so
) in the PHP config instead of a zend_extension
(i.e. zend_extension=/usr/lib/php5/20060613+lfs/xdebug.so
).
Make sure that you don't have an extension=xdebug.so
line anywhere in your PHP config, even if you're pretty sure you're using zend_extension
. For example, if you have zend_extension
in /etc/php5/conf.d/xdebug.ini
, this may well be superseded by an extension
in /etc/php5/apache2/php.ini
. If this is the case, nothing will complain, and phpinfo()
will dutifully report that Xdebug is loaded! (Xdebug 2.1 does issue a small warning in phpinfo()
when loaded as an extension, but previous versions do nothing.)
回答2:
You must add the full path to the xdebug.so
file, even when it's placed in the php/modules/
folder, as zend_extension
doesn't looks in this folder by default.
If you have an exension=xdebug.so
line, xdebug will load but it won't stop at breakpoints (beats me why).
Removing all exension=xdeabug.so
(even from the cli ini file, which also loads) and adding the zend_extension
will solve the issue.
回答3:
If php files are placed into symlink-folder then XDebug will operate with source folder path instead of symlink-folder path!
So to enable breakpoints you should configure path mappings in your ide for symlinked folders and files
回答4:
I know that this has been answered but I came across the same issue just want to offer my answer if anyone else runs across this. I accidentally missed a case value in my paths which still allowed me to connect and run the debugger but it wouldn't stop at my breakpoints. I didn't realized it till much frustration so I just want people to know that that could be a possibility as well.
回答5:
In my case, Eclipse can't pick up the debug info, so enable xdebug log and check the response, returned
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
with no more info.
Fix is to change debug configure
xdebug.remote_host=127.0.0.1 to
xdebug.remote_host=localhost
in /usr/local/etc/php/5.6/php.ini
then restart Apache.
Hope this helps
回答6:
I had this problem on Docker container on Windows. All seemed properly configured, phpStorm properly listening on local port 9000 on 127.0.0.1. phpinfo() displayed the xdebug.so running. When I run the script from the web browser, the debugger failed to stop on the breakopint. The xdebug.log contained this:
Log opened at 2019-07-02 08:17:10
I: Connecting to configured address/port: docker.for.mac.localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///app/www/index.php" language="PHP" xdebug:language_version="7.2.15" protocol_version="1.0" appid="38768" idekey="PHPSTORM"><engine version="2.6.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2019-07-02 08:17:10
I had to ssh into the container to find out that it wasn't connecting out from the container to the Windows, which hosted the container. The problem was, that my docker compose configuration contained docker.for.mac.localhost
which was about to be set into the xdebug.remote_host
setting. Even if the xdebug.log claimed xdebug connected to the client, in fact it didn't connect.
The solution was xdebug.remote_host = host.docker.internal
.
This hostname is used in Docker container to make a local connection to the operating system which is hosting the container.
More info here: https://docs.docker.com/docker-for-mac/networking/
来源:https://stackoverflow.com/questions/3288840/xdebug-successfully-connects-to-dbgp-clients-but-wont-stop-at-breakpoints