Xdebug configurations for Xdebug2 and Xdebug3 under Windows and Linux

In your xdebug.ini file:

; For Xdebug 2 (2.5.5) / Linux
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9003
xdebug.remote_host=172.17.0.1
; For Xdebug 2 (2.5.5) / Windows
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9003
xdebug.remote_host=172.17.0.1
; For Xdebug 3 (3.1.1) / Linux
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20200930/xdebug.so
xdebug.mode=debug
xdebug.discover_client_host=no
xdebug.client_port=9003
xdebug.client_host=172.17.0.1
; For Xdebug 3 (3.1.1) / Windows
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20200930/xdebug.so
xdebug.mode=debug
xdebug.discover_client_host=no
xdebug.client_port=9003
xdebug.client_host=host.docker.internal

Install Xdebug from sources in Dockerfile, docker

Tested on: docker php:5.6.40-fpm

If you need Xdebug version compatibile with older php versions and you can’t do it by PECL.

Download sources to .docker dir e.g. .docker/xdebug-2.5.5.tgz

In Dockerfile:

# Xdebug install from sources
RUN echo \
    && mkdir /usr/local/lib/xdebug
COPY .docker/xdebug-2.5.5.tgz /usr/local/lib/xdebug/xdebug-2.5.5.tgz
RUN echo \
    && cd /usr/local/lib/xdebug/ && tar zxvf xdebug-2.5.5.tgz \
    && cd /usr/local/lib/xdebug/xdebug-2.5.5 \
    && phpize \
    && ./configure --enable-xdebug \
    && make \
    && make install