0
votes

I've setup debug configuration for PhpStorm and it is successfully validated by PhpStorm:

enter image description here

Xdebug helper for Chrome is also installed.

The problem is that nothing happens when I start listening for debug connections and reload the required page with Xdebug helper switched on. Also tried this bookmarklets with no luck.

No errors or something, just nothing.

Also tried to set different IPs as dockerhost: from 192.168.. range (from network settings), from 172.* range (from nginx), from 10.* range (10.0.75.1 is default). Also tried docker.for.mac.internal.host which failed when containers were starting.

Docker 17.02, macOS Sierra, PhpStorm 2017.3

1
"and it is successfully validated by PhpStorm" PhpStorm jut checks that values in php.ini make sense and that port number matches the one in IDE. It does not check the actual connectivity (if Xdebug is able to connect or not).LazyOne
1) Ensure that IDE is listening to xdebug conn (active "phone handle" icon) 2) Ensure that it's PhpStorm that listens on that port and not some other app (e.g. php-fpm) -- sudo lsof -nP -iTCP -sTCP:LISTEN or so 3) Collect xdebug log -- it will tell where it tries to connect and what response is. But in general: the xdebug.remote_host MUST point to the IP where PhpStorm is running (as seen from inside the container; docker.for.mac.internal.host may also work -- I'm not Mac user so cannot say that for sure). 4) You need to disable connect_back as in this case remote_host is ignored. RTM.LazyOne
1) yes; 2) phpstorm 74846 376u IPv4 0x82e89367ea55f7d 0t0 TCP *:9000 (LISTEN); 3) skipped; 4) remote_connect_back - this is it! Thanks! After disabling it I managed to connect! Never thought that it may cause the issue. Its enabled by default in laradock for some reason.Gino Pane

1 Answers

2
votes

If you're on linux, be sure to create corresponding rules in your firewall.

But to troubleshoot this more effectively you need to gather more info.

  1. Enable xdebug logging xdebug.remote_log=/var/www/xdebug.log in you xdebug.ini or you can append that in the "Cli Interpreters > Configuration Options" in PHPStorm (xdebug.remote_log, /path/inside/workspace/container/xdebug.log)

  2. Another step you could take is to monitor the incoming connections to your machine. (run this on where you installed docker). It will start listening to all incoming connection attempts on port 9000.

sudo tcpdump -i any port 9000

Now run the debugger once, check the logs inside the container (workspace by default) and see if any incoming connection attempts have gone through from the container.

If you see something like Time-out connecting to client (Waited: 200 ms). :-(, chances are that your firewall is blocking the incoming connections.

To open them up you could add a rule using ufw

sudo ufw allow in from 172.22.0.0/24 to any port 9000 (or write down a specific ip) Be sure to double check that this is the ip trying to connect

this will allow all connections on port 9000 from 172.22.0.* (which is what laradock uses for its virtual networks). Be sure to double check the logs maybe your setup uses different ip range)

My working xdebug.ini (both in php-fpm and workspace containers are the same)

xdebug.remote_host=dockerhost
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_log=/var/www/xdebug.log

xdebug.cli_color=1
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/path/to/profiler.log"

xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

If none of the above works, another step would be to also check if you have any containers running on port 9000 already. If so, then you'll need to use another, port, just don't forget to expose it from docker.

(Explanation: docker binds (exposes) ports to the host machine so that any incoming connections get directed to the right container, if 9000 is taken, xdebug won't be able to connect to any IDE on your machine, even if the IDE says it is running the listener) Hope this helps.