Setup xdebug on phpstorm and Visual studio code using docker on Windows (Hyper-V)
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:
- http://blog.leanote.com/post/gm8300130/Day-51-Docker-VS-code-Xdebug (use google translate to read it ;-) )
- https://shippingdocker.com/xdebug/get-working/
Collect necessary information
- You need to know the local IP address of your docker host. You can get it in windows like this:
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
- Configure a server
- Configure a PHP-Remote Debugger
Setup Visual Studio Code for using Xdebug
- Install the PHP Debug extension
- Setup the Xdebug configuration to listen to incoming connection
Here you can find my file:
Starting up docker
- Clone the repository: https://github.com/apparena/docker-init
- 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…