0

I want to upgrade to xdebug 3, currently there is installed xdebug 2.

The Dockerfile stars with

FROM debian:10

I have added line

RUN pecl install xdebug && docker-php-ext-enable xdebug

and I get error when building:

Installing '/usr/lib/php/20170718/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.1.5
configuration option "php_ini" is not set to php.ini location
You should add "zend_extension=/usr/lib/php/20170718/xdebug.so" to php.ini
/bin/sh: 1: docker-php-ext-enable: not found
The command '/bin/sh -c pecl install xdebug && docker-php-ext-enable xdebug' returned a non-zero code: 127

The part about xdebug.so is not in red color. But docker-php-ext-enable: not found is in red. So I am not sure why it writes that I should add xdebug.so but not in red.

But there is also a file docker/apache/conf/php/xdebug/20-xdebug.ini which was used for xdebug 2 and there is a line

zend_extension=xdebug.so

so again not clear why it writes to add it.

Also tried:

docker-compose build --no-cache

but getting same error

/bin/sh: 1: docker-php-ext-enable: not found

I have tried this snippet also to install xdebug 3

RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS && \
    pecl install xdebug && \
    docker-php-ext-enable xdebug && \
    printf "xdebug.mode=develop,debug \n\
          xdebug.client_host=host.docker.internal \n\
          xdebug.start_with_request=yes \n" >> /etc/php/$PHP_VERSION/cli/conf.d/20-xdebug.ini && \
    apk del .build-deps && \
    rm -Rf /tmp/*

but it did not work probably because of debian and I do not know how to fix that. Just as long as I can install xdebug 3 and enable, I am fine with the solution. Looks like need to change

RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS

but not sure how.

Darius.V
  • 737
  • 1
  • 13
  • 29
  • Please provide a [mcve]. In any case, you're mixing up Alpine and Debian. What is right in one is not in the other. – Ulrich Eckhardt Aug 22 '22 at 18:23
  • 2
    `docker-php-*` commands exist _only_ in Dockerhub's PHP library images. They are neither built nor endorsed by the PHP organization, and include tooling specific to themselves. If you want to roll your own from a debian base image, then I'd suggest installing everything from apt. – Sammitch Aug 22 '22 at 20:09

1 Answers1

1

As mentioned, use the Debian package manager

FROM debian:10
sudo apt-get install php-xdebug

Note that

For packages that have the PHP version in the package name, such as in php81-php-xdebug3, you can substitute the PHP version with the one that matches the PHP version that you are running.

And, warning

If the package manager installs a version that is no longer supported (see Supported Versions), please install Xdebug with PECL, or from source instead.

pecl install xdebug

xdebug install

Monnomcjo
  • 715
  • 1
  • 4
  • 14
  • Yea, my problem was that I even added `&& docker-php-ext-enable xdebug` .As one guy said it was not needed because I was installing with pecl. – Darius.V Aug 23 '22 at 07:12