WordPress and xDebug Dockerfile

Extend the default WordPress docker container and install and configure the xdebug extension to work with PHPStorm.

Developing WordPress plugins and themes requires a debugger that allows you to step through or profile your code, for this i use xdebug which i have extended the default WordPress docker container to install the xdebug extension and configure it to work with PHPStorm via port 9000 using the idekey PHPSTORM

FROM wordpress:php7.0-apache

ENV XDEBUG_PORT 9000

ARG XDEBUG_REMOTE_HOST=host.docker.internal

RUN 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=1" >> /usr/local/etc/php/conf.d/xdebug.ini && \
    echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/xdebug.ini && \
    echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini && \
    echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini && \
    echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/xdebug.ini && \
    echo "xdebug.idekey=PHPSTORM" >> /usr/local/etc/php/conf.d/xdebug.ini && \
    echo "xdebug.remote_host=$XDEBUG_REMOTE_HOST" >> /usr/local/etc/php/conf.d/xdebug.ini

EXPOSE 9000

Leave a Reply

Fields marked with an * are required to post a comment