13

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:

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.

panosru
  • 2,709
  • 4
  • 33
  • 39
  • 1
    1) Do you really have DBGp Proxy running on your computer? It's simply not needed especially for local Docker... You may have configured it .. but do you actually use it? have you actually installed it etc. Better not to touch it if you do not know how exactly it works. 2) What web server you are using? nginx I guess... If so -- try configuring the server name there 3) *"I also tried to export env variables with and without quotes but the result was the same.."* It has to be **with**. – LazyOne May 03 '18 at 13:21
  • 4) What the full `phpinfo()` output is? I'm after _SERVER / ENVIRONMENT parts only -- need to check if server name is visible there. 5) So far xdebug log says that it's connected to some IDE, most likely PhpStorm... so overall it's good .. just that part left. – LazyOne May 03 '18 at 13:21
  • What exactly do you mean if I really have DBGp proxy running? That is a setting inside PhpStorm and as far as I know, you need that in order to debug remote php servers. The reason I tried both with and without double quote is because of [that](https://github.com/laradock/laradock/issues/363) bug. I'm familiar with remote debugging and I do it many times, but I now testing docker and want to switch over docker completely and while remote debugging works for me everywhere is not working with my docker instance. – panosru May 03 '18 at 17:11
  • @LazyOne I updated my original post to include Environment and PHP Variables section. Everything seems to be fine to me. The thing is that xdebug is connected to PhpStorm, but PhpStorm complains that "Cannot parse server name for external Xdebug connection." – panosru May 03 '18 at 17:17
  • 1) *"What exactly do you mean if I really have DBGp proxy running? That is a setting inside PhpStorm and as far as I know, you need that in order to debug remote php servers."* This means that you do not know how it works and when it's needed. Do not use it as you do not need it. See this if you wish to know when you *may* use it: https://confluence.jetbrains.com/display/PhpStorm/Multi-user+debugging+in+PhpStorm+with+Xdebug+and+DBGp+proxy – LazyOne May 03 '18 at 18:02
  • 2) *"The reason I tried both with and without double quote is because of that bug."* OK... so that's some Docker specific thing or something. I was actually referring to the actual command that you execute in console (i.e. `export PHP_IDE_CONFIG="serverName=SomeName"`) -- here they are needed. – LazyOne May 03 '18 at 18:12
  • 3) *"...but PhpStorm complains that... "* Does it still complains about it? For me (based on your info so far) that setup looks OK -- the other output from `phpinfo()` confirms that PHP_IDE_CONFIG is setup and can be seen by PHP. Maybe show more of your confg from PhpStorm side, e.g. how the server entry is defined there. If I may suggest to check these -- you may find some useful info: https://stackoverflow.com/q/44032296/783119 & https://stackoverflow.com/q/46263043/783119 – LazyOne May 03 '18 at 18:16
  • I updated my original question. Even though that the env variables where setup correctly, when I added env variables to docker-compose.yml then it worked. I'm still not sure why it worked there but anyhow, is working now. I leave that question unanswered though since I believe that having env variables in docker-compose.yml is a duplication. – panosru May 03 '18 at 19:16
  • @LazyOne In regards to DBGp proxy, you are indeed correct, if I recall correctly it was suggested somehwere in PhpStorm youtrack or documentation and I was doing it since then, but I now removed my configuration from DBGp Proxy section and it still works, so yeah.. my bad after all. I'm removing the DBGp Proxy part from my original question and adding the appropriate setting section from PHP > Debug – panosru May 03 '18 at 19:27
  • *"Even though that the env variables where setup correctly, when I added env variables to docker-compose.yml then it worked"* So when it does NOT work .. do you see them in _ENV / _SERVER section of `phpinfo()` output? If you do not see them there ... then PhpStorm will not see them as well... – LazyOne May 03 '18 at 20:03
  • All the screenshots and the info I posted is when is not working. So I see everything correctly when is not working... – panosru May 03 '18 at 20:04

2 Answers2

29

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.

panosru
  • 2,709
  • 4
  • 33
  • 39
  • Just to complete this, you can set this env variable directly in PHPStorm in the config of the CLI Interperters. Just take care to remove the double quotes too. – pvledoux Oct 25 '19 at 09:25
  • Thanks for sharing this with up. For me just putting ` environment: - PHP_IDE_CONFIG=serverName=docker-server` did the fix. you don't really need env_file, just remove the quotes. – Handsome Nerd Apr 23 '20 at 00:33
3

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
Alin Pop
  • 317
  • 2
  • 8