Check the log
Lets say you are running console command something like
in docker container (to those who do not know – it is symfony console command).
Enable logging. I think I myself underestimate the benefit of it. Yes, those logs show lot of spam which is hard to understand but sometimes you can see some useful things. If using xdebug 2, to do that, add to your php.ini for example
Then I rebuilded container using
docker-compose up --build
Not sure if this is needed, maybe somehow can restart php server – but need somehow to make changes of the php.ini work.
To see the logs, you need to go into docker container. You can find here how to do that https://stackoverflow.com/questions/30172605/how-do-i-get-into-a-docker-containers-shell
and see the contents of the file you set in the config xdebug.remote_log.
Can xdebug connect to client?
Check if you see in the log something like
 W: Creating socket for ‘192.168.128.11:9001’, poll success, but error: Operation in progress (29).
 E: Could not connect to client. 🙁
It might be that ip address is wrong. You need IP adress of your host machine. On Ubuntu I got it with this command:
ip addr show
I am not sure exactly which one to choose, this command gives few of them. In my last case this one worked: 192.168.31.26 . I think you can also try those which start with 192 first. Put the address in php.ini config (xdebug 2):
and make sure php see this value (by rebuilding container for example).
Cannot parse server name for external Xdebug connection
Another problem I had – PhpStorm was showing in the event log:
Cannot parse server name for external Xdebug connection.
To fix it create environment variable PHP_IDE_CONFIG on the remote server.
Windows: set PHP_IDE_CONFIG=”serverName=SomeName”
Linux / Mac OS X: export PHP_IDE_CONFIG=”serverName=SomeName”.
It worked to go to docker container shell and run that suggested export. I think need to run it each time container is started if you want xdebug from cmd to work. Probably there is better way but so far only this one I found.
SomeName has to be replaced with value from field Name in PhpStorm:
so for example in my case I need to run in linux
There have been more problems with Xdebug for me but I wrote here recent ones because I remember well how things went, how I solved them. If I will get new problems, I might add more info. Maybe even those few words migth be useful for somebody.
So far I used configs from xdebug 2. If you are using xdebug 3, you can check for equivalent configs here: https://xdebug.org/docs/upgrade_guide .