## The Dockerfile Only add the `xdebug.remote_log` line if you need to troubleshoot. ``` FROM php:7.1-apache 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_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini \ && echo "xdebug.remote_host=172.17.0.2" >> /usr/local/etc/php/conf.d/xdebug.ini \ && echo "xdebug.remote_log=/var/www/html/xdebug.log" >> /usr/local/etc/php/conf.d/xdebug.ini \ && echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/xdebug.ini \ && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini ``` ## Bring up Docker container Run this shell script from the same folder as the Dockerfile
fire-up-docker.sh ``` # stop all containers sudo docker stop $(sudo docker ps -aq) # delete all containers sudo docker rm $(sudo docker ps -aq) sudo docker build -t ctd/xdebug-tester:v1 . sudo docker run \ --detach \ --name my-xdebug-tester \ --volume=/home/chris/my-php-project:/var/www/html \ -p 8080:80 \ -d ctd/xdebug-tester:v1 ``` ## VS Code The php-debug extension configuration file in VS Code
launch.json ```` { "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9000, "log": true, "pathMappings": { "/var/www/html": "/home/chris/my-php-project" } } ] } ````