Docker for Windows requires a well known IP address in order to connect to the host operatingsystem.
Table of Contents
In your PhpStorm Settings go to Languages and Frameworks PHP and click the ‘’ button near the “CLI Interpreter” field. In new window add a new interpreter “From Docker, Vagrant, VM, Remote” choose “Docker Compose” radiobutton, select or create new Server (use Unix socket to. Docker container with PHP+XDebug installed; PHPStorm IDE on my host machine; Debugging PHP scripts # Configure docker container. I am using docker-compose to manage my containers. So let's start with the docker-compose.yml that I put in the root of my PHP project.
![Phpstorm docker setup Phpstorm docker setup](https://fernandoaparicio.net/img/2019/10/debug-test-phpstorm-docker-1.png)
- 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
Open command line
Enter
ipconfig
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:
Directory | Path |
---|---|
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 version | 5.6 |
DockerNAT IP address | 192.168.0.12 |
Virtual Switch IP address | 192.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
.
Important
Remember this, when it comes to path mapping in your IDE/editor configuration.
1. Ensure Xdebug port is set to 9000
2. Set path mapping
![Phpstorm Docker Phpstorm Docker](https://i.stack.imgur.com/7LHuk.png)
Create a new PHP server and set a path mapping. This tutorial assumes your local Devilbox projectsto be in ./data/www
of the Devilbox git directory:
Important
Recall the path settings from the Assumption section and adjust if your configuration differs!
3. Ensure DBGp proxy settings are configured
Note
The following example show how to configure PHP Xdebug for PHP 5.6:
Create an xdebug.ini
file (must end by .ini
):
Copy/paste all of the following lines into the above created xdebug.ini
file:
Important
Ensure you have retrieved the correct DockerNAT
IP address as stated in the prerequisites section above!
Note
![Php docker xdebug phpstorm Php docker xdebug phpstorm](https://imgs.developpaper.com/imgs/4153048563-ab2294e72ce26751_articlex.png)
Phpstorm Docker Path Mappings
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.
Phpstorm Docker Debug
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
Phpstorm Docker-compose
Stop and Restart (Why do docker-composerm
?)
![](https://cdn-ak.f.st-hatena.com/images/fotolife/r/ruriatunifoefec/20200910/20200910011327.png)