2

I'm trying to configure Xdebug with PhpStorm and Laradock.

I started with this: https://laradock.io/documentation/#install-xdebug

I can see that Xdebug is working:

php-fpm/xdebug status
 with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans

This is my PhpStorm config: enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

I added a breakpoint and the debugger is not stopping.

Can anyone see what I am doing wrong?

My project is in /code/test which is /var/www on the server. Laradock is in /code/laradock

UPDATE: Xdebug log shows:

[6] Log opened at 2020-07-10 10:44:55
[6] I: Connecting to configured address/port: host.docker.internal:9000.
[6] E: Time-out connecting to client (Waited: 200 ms). :-(
[6] Log closed at 2020-07-10 10:44:55

Update:

changed ini to this (and port in IDE):

xdebug.remote_host=192.168.68.101
xdebug.remote_connect_back=0
xdebug.remote_port=9001
[6] Log opened at 2020-07-10 12:11:03
[6] I: Connecting to configured address/port: 192.168.68.101:9001.
[6] E: Time-out connecting to client (Waited: 200 ms). :-(
[6] Log closed at 2020-07-10 12:11:04
Mick
  • 1,401
  • 4
  • 23
  • 40
  • 2
    1) Your 2nd screenshot (path mappings): you have mapped remote `/var/www/test` path to both local project root and a subfolder... That's obviously wrong. 2) Show your Xdebug settings (`phpinfo()` output captured in the same way you are trying to debug it: be it browser or a CLI -- it's important as it may have separate php.ini fo CLI and web server -- I'm not using Laradoc myself so not sure on this). The issue must be in using default TCP 9000 port -- php-fpm also uses that port by default. Enable and collect Xdebug log -- it will tell you where it tries to connect (if it tries that at all). – LazyOne Jul 10 '20 at 09:56
  • Right now I may suggest: 1) Change Xdebug port to be 9001 (just in case) in both php.ini and PhpStorm. 2) Make sure that you have "phone handle" icon ON (so IDE is listening for incoming Xdebug connections). Ensure that PhpStorm is the one that listens on that port (e.g. sudo lsof -nP -iTCP -sTCP:LISTEN` or alike). The log says that it simply cannot connect. It could be firewall, IDE not listening .. maybe even some Docker settings... – LazyOne Jul 10 '20 at 11:34
  • 1
    **P.S.** And leave a comment when you edit your post with new info -- there is no guarantee that the person that tries to help you will be regularly checking your post for updates... – LazyOne Jul 10 '20 at 11:35
  • 1
    BTW - what OS you are on? Based on your screensohts it looks like Ubuntu or another Linux, is that correct? if that's so -- `host.docker.internal` does not work on Linux (only on Windows and Mac). https://github.com/docker/for-linux/issues/264 You need to use some workarounds to detect correct IP address – LazyOne Jul 10 '20 at 12:07
  • Ubuntu, just got my ip from ifconfig and added that as xdebug.remote_host. I thought remote_connect_back should work. – Mick Jul 10 '20 at 12:10
  • Well, as per Xdebug log no response at all received... so it's either wrong IP, some firewall, some Docker config issue or IDE is not listening on that port. No other ideas from me right now. – LazyOne Jul 10 '20 at 12:22
  • I'm in, it was the firewall! – Mick Jul 10 '20 at 14:10

1 Answers1

3

I got this working, I had to do a couple of things:

  1. Turned my firewall off.
  2. changed my config:
xdebug.remote_host="172.17.0.1" # this is listed under docker0 using ifconfig
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
Mick
  • 1,401
  • 4
  • 23
  • 40
  • 2
    The laradock docker-compose.yml sets a host under "extra_hosts" that you can use instead of manually specifying the IP address. Thus, you could use the following: xdebug.remote_host=dockerhost. This post might help: https://stackoverflow.com/questions/29076194/using-add-host-or-extra-hosts-with-docker-compose – Tan Jan 19 '22 at 21:26