Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration for Xdebug on macOS #184

Open
RafaelKr opened this issue Aug 3, 2022 · 2 comments
Open

Configuration for Xdebug on macOS #184

RafaelKr opened this issue Aug 3, 2022 · 2 comments

Comments

@RafaelKr
Copy link

RafaelKr commented Aug 3, 2022

Please describe the feature you would like to see implemented.

I just tried to setup debugging with IntelliJ IDEA on a MacBook. For this I set the following in .psh.yaml.override:

const:
  DOCKER_IMAGE_PHP: webdevops/php-apache-dev
  DOCKER_IMAGE_PHP_VERSION: "8.0"

Now we have a container which comes preconfigured with Xdebug. This is already enough on my Linux machine to make it work.

For macOS it was also required to set an additional environment variable for the app_server container:

services:
app_server:
image: shopware/development:7.4-composer-2
networks:
shopware:
aliases:
- docker.vm
extra_hosts:
- "docker.vm:127.0.0.1"
volumes:
- ~/.composer:/.composer
tmpfs:
- /tmp:mode=1777

     extra_hosts: 
       - "docker.vm:127.0.0.1" 
+    environment:
+      XDEBUG_CLIENT_HOST: host.docker.internal
     volumes: 
       - ~/.composer:/.composer 

Actually it's a very few changes to do this but I spent a lot of time to make this work, especially the XDEBUG_CLIENT_HOST took me long to find out.

I think there should be a way to do this more easily, maybe add XDEBUG_CLIENT_HOST: host.docker.internal by default? I just made sure it works also on Linux.
Or at least there should be some documentation about it how to make this work.

@bcremer
Copy link

bcremer commented Aug 4, 2022

The host.docker.internal hostname is not available on linux by default but can be added as extra_host:

    extra_hosts:
      - "host.docker.internal:host-gateway"

Together with XDEBUG_CLIENT_HOST: host.docker.internal this configuration should work on macOS as well as linux.

@RafaelKr
Copy link
Author

RafaelKr commented Aug 4, 2022

Very interesting. You're right that host.docker.internal can't be resolved inside the container but still debugging works inside my IntelliJ.

I created a public/info.php and have set a debug breakpoint on the phpinfo(); line which works. The Info page tells me xdebug.client_host is set to host.docker.internal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants