Search code examples
ddev

How can I use xdebug 3.0 with PHP 7.3 or 7.4 in DDEV?


DDEV-Local v1.16.2 ships with xdebug 3.0 as the xdebug version for PHP8.0 (as of Dec 2020, DDEV-Local v1.16), but I'd like to try out xdebug 3.0 with PHP7.3 or 7.4. How could I do that?

EDIT 2020-12-13: DDEV-Local v1.16.3 ships with Xdebug 3.0.1 as the Xdebug version for PHP7.2/3/4 and PHP8.0


Solution

  • EDIT 2020-12-13: DDEV-Local v1.16.3 ships with Xdebug 3.0.1 as the Xdebug version for PHP7.2/3/4 and PHP8.0, so you don't have to do anything at all!

    DDEV-Local depends on the deb.sury.org Debian packages for PHP, so will follow those as the changes are made. Currently deb.sury.org packages PHP8.0 with xdebug 3.0, but it's not hard to get xdebug 3.0 with earlier PHP versions until that changes.

    You can compile and install xdebug 3.0 for PHP7.3 or 7.4. Place this file as .ddev/web-build/Dockerfile in your project's .ddev directory:

    ARG BASE_IMAGE
    FROM $BASE_IMAGE
    RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests php-dev php-pear build-essential
    RUN pecl install xdebug
    RUN cp /etc/php/8.0/mods-available/xdebug.ini /etc/php/7.4/mods-available/xdebug.ini
    RUN cp /etc/php/8.0/mods-available/xdebug.ini /etc/php/7.3/mods-available/xdebug.ini