Skip to content

bcamargogui/php-xdebug-docker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 👋

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 92.4%
  • PHP 7.6%