
#Phpstorm xdebug setup for mac#
Newer versions of Docker for Mac (17.06 and newer) can conveniently use to connect from the Docker container to the host. XDEBUG_CONFIG env variable sets the remote_host and remote_port Xdebug properties. env "XDEBUG_CONFIG=remote_host= remote_port=9000" \ Variables like remote_host, remote_port or serverName should not be stored in the repository and are runtime specific. docker/xdebug/debug.ini file, but I'd recommend against it. However, Xdebug needs environment or ini file variables to setup the connection to your host machine for live debugging. docker run -rm myapp-xdebug /code/vendor/bin/phpunit -coverage-clover build/logs/clover.xml It may need a bit of tweaking of the file, but the PHPUnit CLI will tell you what to do. You can now run PHPUnit with the code coverage option. Now you can build the image using docker build -file Dockerfile-xdebug -tag myapp-xdebug. The the content of the file took me a while to figure out and is a key to running Xdebug in a CLI app properly. docker/xdebug/xdebug.ini is a local relative path, and the file is stored in the repository. docker/xdebug/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
#Phpstorm xdebug setup install#
RUN pecl install xdebug \Īnd then copy the xdebug.ini setting file. Let's see what commands were added to the original application image.įirst, you need to install and enable Xdebug in the image. I could have used the application image as the source (using FROM), but we tend to keep the image structure as flat as possible, so a plain copy&paste in this case. It is very similar to the original application image. So I have another Docker image and a separate Dockerfile just for Xdebug. Building Xdebug into this image would not be wise, because you don't want to have an image with Xdebug run your production app. This code builds the image with the application, runs the tests on Travis CI, and then (if tests pass) deploys it to AWS ECR. & mv /code/composer.phar /usr/local/bin/composer no-install-recommends & rm -r /var/lib/apt/lists/* RUN apt-get update & apt-get install -y \ The application is based on a very simple Dockerfile.

They simply didn't lead to a working debugger in my setup: I went through a lot of articles touching on the subject, many of them were outdated, focused on web applications or very confusing. code coverage generated when running PHPUnit tests.Having Xdebug in your app will give you 2 major benefits:


We have a nice boilerplate that helps bootstrapping the repository with all the required tools (from integration with Travis CI to static code analysis), but I was missing one piece that comes in handy when I need to debug - a debugger. The majority of my coding are simple CLI applications.
