- For your local dev, create a
Dockerfilethat is based on your production image and simply installxdebuginto it. Exemple:
FROM php:5
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=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
- Get you local IP address (
ip -o -4 addr list ${MY_NETWORK_INTERFACE:-eth0} | awk '{print $4}' | cut -d/ -f1) - Start your container with the following environment variables:
XDEBUG_CONFIG="remote_host={{YOUR_IP_ADDRESS}}"
-
Simple
dockerrun:docker run -e XDEBUG_CONFIG="remote_host={{YOUR_IP_ADDRESS}}" your-image -
With
docker-compose:# docker-compose.yml foo: build: path/to/Dockerfile environment: XDEBUG_CONFIG: "remote_host={{YOUR_IP_ADDRESS}}" PHP_IDE_CONFIG: "serverName=my.local"
- In Intellij/PHPStorm go to:
Languages & Frameworks>PHP>Servers> and set the following settings:
- Name: name of your server, should be equal to value in
PHP_IDE_CONFIGvariable
Then you're all set and can start listening for PHP Debug connections from your IDE.
Happy debugging!





Hello,
I followed your tutorial but i'm stuck. I start to listening PHP Debug Connection, i add a key with XDEBUG_SESSION_START on my host (ex : http://localhost/?XDEBUG_SESSION_START=phpstorm-xdebug) with breakpoint on my code and nothing happens.
I even add a die(); near my breakpoint to be sure code is evaluated and it is.
What can i do to debug things and find why it's nor working.
Edit : I get it. So i add a remote_log option in order to find what happened. I saw a timeout error. After a while, i realised that i have a firewall on my system. After opening the TCP port 9000 it works perfectly.