Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot parse server name for external Xdebug connection

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:

enter image description here

xdebug.log

Here is the xdebug section from my phpinfo(): enter image description here enter image description here

And these are my settings for PhpStorm:

enter image description here

enter image description here

Environment from phpinfo():

enter image description here

PHP Variables from phpinfo():

enter image description here enter image description here enter image description here

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

enter image description here

You can also check the following files in cases needed:

  • Dockerfile.development
  • docker-compose.yml
  • environment.development
  • php.ini

Any help will be much appreciated!

Update:

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.

like image 619
panosru Avatar asked May 03 '18 13:05

panosru


2 Answers

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: enter image description here

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(): enter image description here

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.

like image 55
panosru Avatar answered Oct 19 '22 00:10

panosru


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
like image 35
Alin Pop Avatar answered Oct 18 '22 23:10

Alin Pop