Setup xdebug on phpstorm and Visual studio code using docker on Windows (Hyper-V)

Sebastian Buckpesch
2 min readJun 28, 2017

--

After two days of struggeling I finally made it to have my code breaking within PHPStorm and Visual Studio code. To make it easier for you I will write down a step-by-step guide, host my code in a Github repository and link all references, which helped my with the setup.

My environment is:

  • Windows 10 Pro using Hyper-V virtualization
  • Docker for Windows

References:

Collect necessary information

  1. You need to know the local IP address of your docker host. You can get it in windows like this:
Local IP address of the Virtual Switch created when setting up docker using Hyper-V: https://docs.docker.com/machine/drivers/hyper-v/

On a mac you can get the IP address by typing ipconfig getifadd en1 (see https://shippingdocker.com/xdebug/get-working/).

Setup PHP-Storm for using Xdebug

  1. Configure a server
  2. Configure a PHP-Remote Debugger
1. Create a new PHP server using exactly (!) the settings above.
2. Create a new PHP Remote Debug configuration using the newly created server

Setup Visual Studio Code for using Xdebug

  1. Install the PHP Debug extension
  2. Setup the Xdebug configuration to listen to incoming connection
1. Install the PHP Debug Extension
2. Update the launch.json configuration file and setup the missing path mapping

Here you can find my file:

Visual Studio Code launch.json for using Xdebug

Starting up docker

  1. Clone the repository: https://github.com/apparena/docker-init
  2. Run docker-compose up to get started

Then you are done :-) Try to set a breakpoint on your index.php file and start listening to it from vscode or PHPStorm…

--

--

Sebastian Buckpesch

I write about AWS and cloud topics. I’m interested in User experience, Web, Internet of things and Automation. Portfolio: https://buckpesch.io/