Skip to content
Debug PHP with Xdebug inside Docker. Tested with PhpStorm and VS Code.
Dockerfile PHP
Branch: master
Clone or download
Latest commit 1a8df06 Jul 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode Add .vscode/launch.json Jul 29, 2019
Dockerfile Inital commit May 4, 2019
README.md Inital commit May 4, 2019
docker-compose.yml Inital commit May 4, 2019
index.php Inital commit May 4, 2019

README.md

PHP/Xdebug/Docker example

Debug PHP with Xdebug inside Docker. Tested with PhpStorm and VS Code.

Usage

The Xdebug config happens in the Dockerfile. I recommend to look at it, escpeially the comments. The most important part is the xdebug.remote_host which has to be set to the Docker host.

A sample docker-compose.yml comes along with it so you can get this up and running in one command: docker-compose up --build -d.

VS Code configuration

Install the felixfbecker.php-debug extension.

You can create a debug configuration by going to Debug > Add Configuration... > PHP, but I've included the .vscode/launch.json file in the repo, with the correct folder maping.

Add a breakpoint, and click on "Listen for XDebug" in the top left hand corner. Load your page, and you should get debugging information:

PhpStorm configuration

You should not have to configure anything since we use the default debug port etc.

Add a breakpoint and start listening for Xdebug in the top right hand corner:

Load your page. PhpStorm will prompt you to add a "server" with a folder mapping:

And then magic happens:

Enjoy 👋

You can’t perform that action at this time.