Skip to content

Commit

Permalink
custom xdebug and extra_hosts to make host.docker.internal works! tha…
Browse files Browse the repository at this point in the history
  • Loading branch information
tmy2017 committed Feb 20, 2022
1 parent 3928974 commit ca57066
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 10000 ,
"port": 9001,
"pathMappings": {"/var/www": "${workspaceRoot}"},
"log": true
},
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ services:

php:
image: prooph/php:7.1-fpm-xdebug
extra_hosts : [ host.docker.internal:host-gateway]
links:
- mariadb:mariadb
volumes:
- .:/var/www
- ./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini

mariadb:
image: mariadb
Expand Down
13 changes: 13 additions & 0 deletions xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
zend_extension=xdebug.so
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
; port 9000 is used by php-fpm
; tmy: change to 9001 so phpstorm can directly use it zz-_07-_y22-0220-1625
xdebug.remote_port=9001
xdebug.remote_autostart=1
; !!!NOTICE!!! MUST remember to do extra_hosts in docker-compose.yml or do for docker run --add-host host.docker.internal:host-gateway
; Ref: https://github.com/gitpod-io/gitpod/issues/6446
xdebug.remote_host=host.docker.internal
;not useful - tried in docker not working to connect back to host machine zz-_07-_y22-0220-1614
;xdebug.remote_connect_back=1

1 comment on commit ca57066

@Eetezadi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do not have an docker-compose.yml, how can I do "do for docker run --add-host host.docker.internal:host-gateway" and where?

Please sign in to comment.