Docker - xDebug with PHPStorm


Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 569 of /homepages/46/d762693627/htdocs/dc/includes/
Docker - xDebug with PHPStorm

If you enable xdebug in your server every time we run a script in PHP is going to send the information to the listener, the Listener in our case is PHPStorm. First of all you must have your PHP image up and running, but sadly you cant use the official one, you will need to build your own image, you can use this small script that I have wrote

FROM php:7.0-apache

# xDebug requires the followings:
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y \
    && apt-get install -y git libmcrypt-dev libpng12-dev libjpeg-dev libpq-dev mysql-client curl \
    && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
    && docker-php-ext-install mcrypt gd mbstring pdo pdo_mysql zip \
    && pecl install xdebug \
    && rm -rf /tmp/pear \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=on\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=off\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_port=9000\n" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && curl -sS | php -- --install-dir=/usr/local/bin --filename=composer

# xDebug requires set remote_host in php.ini.
COPY php.ini /usr/local/etc/php/

At the bottom of the code above, I copy php.ini into php container. So I can overwrite the default php.ini information, so what does this php.ini contain, look at this :

memory_limit = 128M
post_max_size = 100M
upload_max_filesize = 200M
;remember to change this to your local ip address. To get it by running ifconfig in MAC terminal

as you can see, its only overwrite the information about the upload limitation and a very important value which is xdebug.remote_host this should contain your local machine IP , and in my case its You can check by running ifconfig in your MAC terminal.

Next, we need to config phpstorm to listen xdebug.

Pressing “⌘ ,” we go to the Preference menu, in the search area we look for “xdebug” and we should configure as in the picture as follow.


blog tag: