1
votes

I'm running PhpStorm on Ubuntu 16.04 and trying to configure Xdebug to work with Docker. And I followed this guide:

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

Here's step I did:

Download the Docker Xdebug project source code provided by JetBrains

Edit Xdebug remote host:

Edit Xdebug remote host

Configure DBGp Proxy (under Language & Framework => PHP => Xdebug) as following:

DBGp Proxy

Edit Run/Debug Configuration

Run/Debug Configuration

Run/Debug Configuration

Edit Build, Execution, Deployment for Docker

Build, Execution, Deployment

Start Docker

Start Docker

Enable Listening Xdebug Connection

Listening Xdebug Connection

Check Xdebug info

Xdebug info

But somehow, I cannot start the Xdebug button (as you can see in the above photo).

What did I do wrong?

1
Well .. you have started the Docker container. Now you need to launch your web app and tell xdebug that you want to debug it. This can be done via specific [bookmarklet ](jetbrains.com/phpstorm/marklets) or via xdebug extension for your browser -- either of them will set the xdebug cookie .. so when you reload the page (or click any other link/button on that page so it will load other URL) it will send that cookie to xdebug. - LazyOne
P.S. I'm not sure about the need to map 9000 port in docker as it's xdebug that connects to PhpStorm and not other way around. You may also enable collecting xdebug logs to see what's going on from xdebug side: xdebug.org/docs/all_settings#remote_log - LazyOne
Try to add query paramter "XDEBUG_SESSION_START=PHPSTORM" to the URL but not work. Plus, I can even click the debug button. - petwho
You cannot click the debug button (as per your 2nd from last screenshot) because that's for launching Docker only (which in general can be used with any technology: PHP, Ruby, Python, Java ect). For PHP debugging you may create and use "Web App" type of configuration (use it after Docker was launched) or via bookmarklet/extension (like original manual from PhpStorm site is suggesting). - LazyOne
You may also just use xdebug.remote_autostart = on to tell xdebug that it needs to debug every single request (in case if you cannot make it work via xdebug cookie/query parameter). - LazyOne

1 Answers

4
votes

Somehow the docker container cannot access port 9000 on host machine. By running the following command I fixed the problem:

# iptables -I INPUT -p tcp -m tcp --dport 9000 -j ACCEPT