Skip to content

Instantly share code, notes, and snippets.

@kzap
Created August 8, 2018 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzap/fccce076a9fd7ea05d67538ed8cd8938 to your computer and use it in GitHub Desktop.
Save kzap/fccce076a9fd7ea05d67538ed8cd8938 to your computer and use it in GitHub Desktop.
Connect to Xdebug running inside your PHP Container by building an image with Xdebug installed and running like this: `docker-compose -f docker-compose.xdebug.yml up`. Then the PHP inside your editor will connect to Xdebug running in your editor.
DOCKER_HOST_IP=IP.OF.YOUR.HOST.MACHINE.FROM.INSIDE.DOCKER
FROM FROM php:7.0-apache
RUN pecl install xdebug
ARG HOST_IP
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo '[xdebug]'; \
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)"; \
echo 'xdebug.remote_enable=1'; \
echo 'xdebug.remote_autostart=1'; \
echo 'xdebug.remote_log="/tmp/xdebug.log"'; \
echo "xdebug.remote_host=$HOST_IP"; \
} > /usr/local/etc/php/conf.d/xdebug.ini
# docker-compose -f docker-compose.yml -f docker-compose.xdebug.yml up
version: '3.2'
services:
web:
image: your-container:xdebug
build:
context: .
dockerfile: Dockerfile.xdebug
args:
HOST_IP: "${DOCKER_HOST_IP}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment