Search code examples
nginxdockerphpstormxdebugboot2docker

Xdebug with PHPStorm and a Docker container


Setup: Windows 10; Docker running with Boot2Docker on Hyper-V; PHPStorm 9

Webserver on the VM is Nginx. I've configured the xdebug.ini for php5-fpm as:

zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_port=9000
xdebug.remote_connect_back=On
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0

If I set a breakpoint and reload the page I get an incoming connection from Xdebug in PHPStorm:

Incoming connection

I wonder that there is only one file shown and not the entire project which is much bigger. If I accept the connection I can debug the very first line but it is not stopping on my breakpoint and creates a server entry which looks like:

Server What is very strange that host is empty. I already added the server with the correct mapping but it got ignored.

So how to get Xdebug to stop on breakpoints?


Solution

  • What is very strange that host is empty.

    PhpStorm requires this field to be filled as it uses this to recognize what server entry (and therefore path mappings) to use -- IDE supports debugging the same code base running on different domains / remote servers.

    In this particular case the servername field / parameter of your nginx configuration is empty. You can fix this by providing some value in nginx config file.