我正在使用PhpStorm在本地运行我的Symfony应用程序。为了进行调试,我安装了Xdebug以及相应的Chrome浏览器帮助程序扩展。
一般工程中的调试。例如,如果我在Symfony类doDispatch()
内的Symfony\Component\EventDispatcher
函数中放置一个断点并启动服务器,则断点将触发,并且我可以逐步执行代码。
但是,当我通过自己的代码调用该方法时,将忽略相同的断点。即使我在服务器启动后在断点上打了一个勾号,也无法识别我在自己的控制器/服务中放入的任何断点。
这是我添加到php.ini
中的内容:
zend_extension = /usr/lib/php/modules/xdebug.so
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.remote_cookie_expire_time = 3600
xdebug.remote_enable = 0
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
这是我启动时的服务器输出:
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /home/.../bin/console server:run
[OK] Server listening on http://127.0.0.1:8001
// Quit the server with CONTROL-C.
我已经尝试了localhost:8000
和127.0.0.1:8001
进行调试,但是它们都不会触发我的断点。
仅供参考,我确实开始在PhpStorm中侦听PHP调试连接,并在浏览器扩展程序中开始调试。
我正在使用PHP 7.3.1版和Xdebug的最新Beta版。
xdebug.log
到达一条其控制器中具有断点的路线后:
[28601] Log opened at 2019-01-29 15:54:28
[28601] I: Checking remote connect back address.
[28601] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[28601] I: Checking header 'REMOTE_ADDR'.
[28601] W: Remote address not found, connecting to configured address/port: 127.0.0.1:9000. :-|
[28601] I: Connected to client. :-)
[28601] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/.../bin/console" language="PHP" xdebug:language_version="7.3.1" protocol_version="1.0" appid="28601" idekey="11916"><engine version="2.7.0beta1"><![CDATA[Xd$
[28601]
[28601] <- feature_set -i 1 -n show_hidden -v 1
[28601] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>
[28601]
[28601] <- feature_set -i 2 -n max_depth -v 1
[28601] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>
[28601]
[28601] <- feature_set -i 3 -n max_children -v 100
[28601] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>
[28601]
[28601] <- feature_set -i 4 -n extended_properties -v 1
[28601] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="4" feature="extended_properties" success="1"></response>
[28601]
[28601] <- status -i 5
[28601] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="5" status="starting" reason="ok"></response>
[28601]
[28601] <- step_into -i 6
[28601] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="6" status="break" reason="ok"><xdebug:message filename="file:///home/.../bin/console" lineno="9"></xdebug:message></response>
[28601]
[28601] <- breakpoint_set -i 7 -t line -f file:///home/.../src/Controller/HostController.php -n 30
[28601] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="286010001"></response>
[28601]
[28601] <- stack_get -i 8
[28601] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="8"><stack where="{main}" level="0" type="file" filename="file:///home/.../bin/console" lineno="9"></stack></response>
[28601]
[28601] <- run -i 9