I am trying to get Xdebug 3 to run on GitPod with Apache. Installation works well, also "Launch on currently open script".
The challenge is to connect Xdebug to the debug client. That seems to fail if one is just using xdebug.client_host = localhost
, because of the Docker environment. Normally one would use xdebug.client_host = host.docker.internal
, but simply declaring that does not work on GitPod.
2
Answers
With help on the Gitpod Discord, here is the solution. It is implemented in the repo on Github.
No changes or pathmappings in VScode needed. Default
launch.json
works.Xdebug settings for "Listen to Xd" to be copied to Apache (e.g. /etc/php/8.2/apache2/conf.d/99-custom.ini)
Xdebug settings for CLI to be copied (e.g. /etc/php/8.2/cli/conf.d/)
Docker caches the copy commands and this can lead to a lot of confusion when debugging. So I moved them to the .gitpod.yml, which also initializes the ports and installs the php-debug extension for VScode.
To implement this in your Gitpod setup, you might need to update the custom Docker image and incorporate a similar
extra_hosts
configuration..gitpod.dockerfile
:That would include the
extra_hosts
configuration similar to the one in thedocker-compose.yml
from the provided GitHub commit.That way, you can check if
host.docker.internal
can be resolved correctly within your Gitpod environment.