Installing XDebug in Docker Installing XDebug in Docker docker docker

Installing XDebug in Docker


I solved this by adding the following lines into my Docker file:

FROM php:7.0-apacheRUN a2enmod rewriteRUN docker-php-ext-install pdo pdo_mysqlRUN yes | pecl install xdebug \    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.iniCOPY php.ini /usr/local/etc/php/COPY . /var/www/html/


try this:

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


As of PHP 7.4 you only need this

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

And add this line to enable remote debugging

&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \&& echo "xdebug.remote_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \