Chris Stryczynski
Chris Stryczynski

Reputation: 33861

How do I install XDebug on docker's official php (debian based) image?

Exactly as How do I install XDebug on docker's official php-fpm-alpine image? but instead of the alpine image I'm looking for the debian based image (php:7.1-fpm-stretch).

Essentially, how should I install XDebug? Through Debian's packages? pecl? Or some alternative?

Upvotes: 0

Views: 4431

Answers (2)

Luke Waite
Luke Waite

Reputation: 2475

The official image documentation indicates that you can use pecl to install xdebug. Since xdebug is not available through other channels, this is the preferred method.

Some extensions are not provided with the PHP source, but are instead available through PECL. To install a PECL extension, use pecl install to download and compile it, then use docker-php-ext-enable to enable it:

FROM php:7.1-fpm-stretch
RUN pecl install xdebug-2.6.0 \
    && docker-php-ext-enable xdebug

For <= PHP 5.6.?:

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

Upvotes: 8

Chris Stryczynski
Chris Stryczynski

Reputation: 33861

In addition to installing it I had to do the following in order to get it working:

/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_connect_back = 1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_log="/tmp/xdebug.log"

And also set a environment variable in my docker config for the container:

  - PHP_IDE_CONFIG=serverName=exampleAbc

Upvotes: 1

Related Questions