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

Find a way to get xdebug working without setting IP address in .env #8

Open
derschatta opened this issue Nov 20, 2018 · 4 comments
Open

Comments

@derschatta
Copy link
Member

Is your feature request related to a problem? Please describe.
Currently you need to set the IP address of the host manually in the .env file to get xdebug working properly. If you are always on the same network with the same IP address this is no problem but as soon as you switch you might need to change it manually which is annoying.

Describe the solution you'd like
Ideally you don't need to set the IP address but the system automatically detects it and xdebug works out of the box.

Additional context
One possible way could be to use xdebug.remote_connect_back as described here: https://xdebug.org/docs/remote

@derschatta derschatta added the enhancement New feature or request label Nov 20, 2018
@derschatta derschatta changed the title Find a way to automatically detect current IP address for xdebug Find a way to get xdebug working without setting IP address in .env Nov 20, 2018
@derschatta
Copy link
Member Author

derschatta commented Nov 21, 2018

For Mac I found an easy way to achieve this and committed it in 616bb29.
On Docker for Mac there's a dns name which always points to the host.
On Linux there's no such thing but it's easy to find the internal IP of the host from the docker container, I've added instructions for the env.dist file for that as well.

I'll leave this issue open in case there are better solutions which work out of the box across platforms.

@codyfinegan
Copy link
Member

May or may not be useful, you can now use the "host-gateway" key to auto-assign a custom domain to the host IP.
https://stackoverflow.com/questions/31324981/how-to-access-host-port-from-docker-container/43541732#43541732
eg

extra_hosts:
      - "my-custom-domain:host-gateway"
      - 

Could be used to eliminate the .env IP address

@derschatta
Copy link
Member Author

May or may not be useful, you can now use the "host-gateway" key to auto-assign a custom domain to the host IP. https://stackoverflow.com/questions/31324981/how-to-access-host-port-from-docker-container/43541732#43541732 eg

extra_hosts:
      - "my-custom-domain:host-gateway"
      - 

Could be used to eliminate the .env IP address

nice find. have you tested this? I am on Mac so cannot really test it.

Might just be enough to set this on the php compose part:

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

and make sure the HOST_IP setting in the .env is

HOST_IP=host.docker.internal

@codyfinegan
Copy link
Member

I'll give it a go when I get some time - I use xdebug myself in my direct non-docker PHP. I ran into this setting in another docker thing and thought it might be useful.

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

No branches or pull requests

2 participants