phpmagentophpstormxdebugwarden.dev

Connect PhpStorm debugger to Xdebug with Warden


I'm getting an old Magento 1 project up and running, and am hitting issues getting the debugger working. Everything is run on Docker, using Warden to manage the different containers. I've followed the the instructions for setting up the debugger in Warden's docs as well as looked at this post, but can't seem to get it connected.

To start: I've installed the Xdebug browser extension, and verified that Warden has switched from using the php-fpm docker container to the php-debug container (by checking the logs when running warden env logs --tail 0 -f php-debug).

Then I created a PhpStorm server configuration as detailed in the docs - I set name to sa1-docker, host to 127.0.0.1, port to 80, selected the Xdebug debugger option, and then mapped the project files to /var/www/html (see screenshot).

PhpStorm server configuration window

Next, I set up a PHP Remote Debug configuration - I selected the sever created above, and set the IDE key (session ID) to "PHPSTORM". (see next screenshot)

PhpStorm run configuration window

I then run that configuration, and see that PhpStorm is "waiting for incoming connection with IDE key 'PHPSTORM'". However, when I place a breakpoint and reload the page, PhpStorm never picks up the connection.

According to Warden's documentation, Xdebug will automatically connect back to the host machine on port 9000 for xdebug2 and 9003 for xdebug3 for each request routed to the php-debug container - however, it doesn't seem like this is happening, and I'm honestly not sure how to debug this further.

Thanks in advance!


Solution

  • @LazyOne Thank you so much for your help - I did have to create a PhpStorm server configuration (not sure why it didn't do it automatically), but deleting the PHP remote debug configuration and using the "Zero configuration debugging" worked and was definitely a lot easier.

    I added the xdebug_info(); line, and that helped show me what I was missing. It turned out that the xdebug.mode was only develop, and not debug. On top of that, XDebug was using the wrong client_host. I added these lines to my warden-env.yml file, and things started working:

      php-debug:
        environment:
          XDEBUG_MODE: "debug,develop"
          XDEBUG_CONFIG: "client_host=host.docker.internal"