I have a Docker container with xdebug in it, when I run the script I need to form the Docker container I receive from PhpStorm the following message:
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".
but I have already set those environment variables as you can see in the screenshot here:
xdebug.log
Here is the xdebug section from my phpinfo()
:
And these are my settings for PhpStorm:
Environment from phpinfo()
:
PHP Variables from phpinfo()
:
I also tried to export
env variables with and without quotes but the result was the same...
With quotes:
XDEBUG_CONFIG="remote_host=192.168.1.110"
PHP_IDE_CONFIG="serverName=docker-server"
Without quotes:
XDEBUG_CONFIG=remote_host=192.168.1.110
PHP_IDE_CONFIG=serverName=docker-server
The result from ifconfig en1 inet
command from my MacOS where I'm running Docker and PhpStorm
You can also check the following files in cases needed:
Any help will be much appreciated!
Seems that if I add
environment:
XDEBUG_CONFIG: "remote_host=192.168.1.110"
PHP_IDE_CONFIG: "serverName=docker-server"
into my php
service located inside docker-compose.yml it solves the issue but leaves me with a big question.
Since I have:
env_file:
- ./etc/environment.yml
- ./etc/environment.development.yml
and inside ./etc/environment.development.yml
I have:
XDEBUG_CONFIG="remote_host=192.168.1.110"
PHP_IDE_CONFIG="serverName=docker-server"
And since it is not ignored and I can see that those Env variables are set even before I add environment
property into my php
service, why xdebug is only triggered when I have set the environment
property? It feels like duplication for me to have it in both places and I prefer to have it inside ./etc/environment.development.yml
rather than docker-compose.yml
.
After some more digging,
I saw the following difference:
When I use env_file
directive I had the following in my environment.development
file:
XDEBUG_CONFIG="remote_host=192.168.1.110"
PHP_IDE_CONFIG="serverName=docker-server"
which resulted in:
Notice the double quotes around the value.
When I was removing env_file
directive and put the following:
environment:
XDEBUG_CONFIG: "remote_host=192.168.1.110"
PHP_IDE_CONFIG: "serverName=docker-server"
Then I had this in phpinfo()
:
So in the end what I did was, I removed environment
directive and put back the env_file
directive and inside environment.development
file I removed the double quotes around the value, so now it looks like that:
XDEBUG_CONFIG=remote_host=192.168.1.110
PHP_IDE_CONFIG=serverName=docker-server
And now it works fine :)
I filled a bug report in PhpStorm youtrack.
I had the same issue with double quotes but in docker-compose. First version was wrong, removing double quotes solved it:
environment:
- PHP_IDE_CONFIG="serverName=local"
- PHP_IDE_CONFIG=serverName=local
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With