Open forethoughtde opened 5 years ago
You have at least to uncomment
PHP_XDEBUG_REMOTE_HOST: 172.17.0.1 # Linux, Docker < 18.03
so PHP knowns where to talk to. But by adding
PHP_XDEBUG_REMOTE_LOG: /tmp/php-xdebug.log
you can check whether the connection works.
Now I see with tail -f /tmp/php-xdebug.log
Log opened at 2019-01-08 11:14:00
I: Connecting to configured address/port: 172.17.0.1:9000.
I: Connected to client. :-)
so my local side (VS Code) is connected with xdebug. Unfortunately the breakpoints do not stop either.
See my PRs #347 and #348 and below my index.php and xdebug log out. Hope that helps?
<?php
echo "HELLO";
phpinfo();
Log opened at 2019-01-08 11:27:54
I: Connecting to configured address/port: 172.17.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/web/index.php" language="PHP" xdebug:language_version="7.2.13" protocol_version="1.0" appid="92" idekey="www-data"><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>
<- 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_set -i 2 -t line -f file:///home/clemens/Documents/projects/docker4drupal/web/index.php -n 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="920003"></response>
<- breakpoint_set -i 3 -t line -f file:///home/clemens/Documents/projects/docker4drupal/web/index.php -n 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="920004"></response>
<- breakpoint_list -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"><breakpoint type="line" filename="file:///home/clemens/Documents/projects/docker4drupal/web/index.php" lineno="5" state="enabled" hit_count="0" hit_value="0" id="920004"></breakpoint><breakpoint type="line" filename="file:///home/clemens/Documents/projects/docker4drupal/web/index.php" lineno="3" state="enabled" hit_count="0" hit_value="0" id="920003"></breakpoint></response>
<- breakpoint_list -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"><breakpoint type="line" filename="file:///home/clemens/Documents/projects/docker4drupal/web/index.php" lineno="5" state="enabled" hit_count="0" hit_value="0" id="920004"></breakpoint><breakpoint type="line" filename="file:///home/clemens/Documents/projects/docker4drupal/web/index.php" lineno="3" state="enabled" hit_count="0" hit_value="0" id="920003"></breakpoint></response>
<- breakpoint_set -i 6 -t exception -x *
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="920005"></response>
<- run -i 7
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="7" status="stopping" reason="ok"></response>
<- stop -i 8
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stop" transaction_id="8" status="stopped" reason="ok"></response>
Log closed at 2019-01-08 11:27:54
Hmmm .... reading https://github.com/felixfbecker/vscode-php-debug/issues/195 I changed my index.php
<?php
echo 1/0;
echo "HELLO";
phpinfo();
and now VS Code breaks and claims Unable to open 'index.php': File not found (file:///var/www/html/web/index.php).
Thanks to a hint on https://enrise.com/2018/02/debugging-php-with-xdebug/ then use the newer path mapping my debug session works as expected.
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www/html": "/home/clemens/Documents/projects/docker4drupal"
}
},
@forethoughtde try to debug xdebug connection.
Also, you may try this config:
PHP_XDEBUG=1
PHP_XDEBUG_DEFAULT_ENABLE=1
PHP_XDEBUG_REMOTE_HOST=host.docker.internal
PHP_IDE_CONFIG=serverName=my-ide # Should be the same as in your IDE.
PHP_XDEBUG_REMOTE_CONNECT_BACK=0
In this case you don't need Chrome helper plugin.
Yes, see the above reference. I beat my head against this for several days and finally discovered that downgrading to PHP 7.1 fixed the issue. I haven't tried 7.2.
Codebase Built-in vanilla Drupal or mounted codebase
Describe your issue XDebug is not stopping the execution on breakpoints. I have installed XDebug Helper Chrome plugin and add a breakpoint to the custom module php file.
I followed this instructions to set up docker-compose.yml file and run make command. https://wodby.com/docs/stacks/drupal/containers/#xdebug-local. I also configured the PHPStrom as described in the document as well.
Output of
docker info
Contents of your
docker-compose.yml
Contents of your
.env
Logs output
docker-compose logs