Docker Compose Xdebug

Apr 07, 2019 I am going to show using Xdebug with Docker. Because, as long as you prefer using Xdebug on development workspace with Docker, you have to create remote connection of the Xdebug. First of all, you must have a Xdebug client. I would rather use PhpStorm for this. With this way, I am going to mention some hints and ways to use smoothly. See full list on brunopaz.dev. Xdebug configuration xdebug.remoteenable = 1 xdebug.remoteport = 9099 xdebug.remoteautostart = 1 xdebug.remoteconnectback = 0 xdebug.remotehost = 192.168.0.30 Run docker-compose build to get the latest version of your image. Set the remote host to whatever your internal network IP is.

Docker for Windows requires a well known IP address in order to connect to the host operatingsystem.

Table of Contents

  • Prerequisites
  • Configuration

Ensure you know how to customize php.ini values for the Devilbox and have a rough understandingabout common Xdebug options.

On Windows you will have to manually retrieve the IP address to which Xdebug should connect tovia xdebug.remote_host.

When you have done no custom configuration in your Virtual Switch manager, Docker for Windows willuse the DefaultSwitch automatically.

Windows: Virtual Switch Manager example screenshot

  1. Open command line

  2. Enter ipconfig

  3. Look for the IP4 address in DefaultSwitch (e.g.: 192.168.0.12)

Important

192.168.0.12 is meant as an example and will eventually differ on your system.Ensure you substitute it with the correct IP address.

For the sake of this example, we will assume the following settings and file system paths:

Docker Compose Xdebug
DirectoryPath
Devilbox git directory/home/cytopia/repo/devilbox
HOST_PATH_HTTPD_DATADIR./data/www
Resulting local project path/home/cytopia/repo/devilbox/data/www
Selected PHP version5.6
DockerNAT IP address192.168.0.12
Virtual Switch IP address192.168.0.12

The Resulting local project path is the path where all projects are stored locally on yourhost operating system. No matter what this path is, the equivalent remote path (inside the Dockercontainer) is always /shared/httpd.

Best digital alarm clock for kids. Important

Remember this, when it comes to path mapping in your IDE/editor configuration.

Ensure you have vscode-php-debug installed for Visual Studio Code.

You will need to configure the path mapping in launch.json (VSCode configuration file):

Important

Recall the path settings from the Assumption section and adjust if your configuration differs!

Important

The above example configures Xdebug for a single project mytest. Add more projects as you need.

See also

Note

The following example show how to configure PHP Xdebug for PHP 5.6:

Php - Setting Up Xdebug With Docker Compose And WordPress ..

Create an xdebug.ini file (must end by .ini):

Copy/paste all of the following lines into the above created xdebug.ini file:

Important

Docker Compose Xdebug 3

Ensure you have retrieved the correct DockerNAT IP address as stated in the prerequisites section above!

Note

Host os and editor specific settings are highlighted in yellow and are worth googling to get a better understanding of the tools you use and to be more efficient at troubleshooting.

Restarting the Devilbox is important in order for it to read the new PHP settings.Note that the following example only starts up PHP, HTTPD and Bind.

See also

Stop and Restart (Why do docker-composerm?)