Debug PHP using Docker, VS Code, and XDebug

preview_player
Показать описание
In this video (the much-anticipated sequel to my "Debugging PHP in WSL and VS Code" video, linked below), I show how to set up a development-style docker image complete with XDebug and a configuration that allows you to debug directly from VS Code.

This will work whether you use Windows Subsystem for Linux or are developing solely on Windows and even if you're running on Mac OS or Linux.

Рекомендации по теме
Комментарии
Автор

THANK YOU!! I search for this solution in several forums, articles, and blogs, but yours is the only one that worked for me! Thanks for all the in depth detail. You rock

picklebrownie
Автор

In the name of GOD. I spent whole weekend trying to integrate vsc, docker compose and xdebug. Even chat gpt did not help me with this case. But after copying your config data it worked. Thanks a lot

kamilwojtalak
Автор

Thank you very much for this video, really help me to understand Xdebug and run with my environment and app: WSL2 + Docker + PHP 5.6 (cakephp 1.3) to upgrade that

mdjg
Автор

Hey Brian, I really appreciate the in-depth discussion on setting up xDebug in this environment. I've been trying to get xDebug setup on my current project of ages, unfortunately your vid didn't get my issue solved. I have a multi docker (Laradock) setup, and setting vscode xdebug port to the same port as in my php-fpm container always results in EADDRINUSE: address already in use 0.0.0.0:9003. I'm posting here in the hope you might have a simple solution.

danielfloris
Автор

Hi Parkour, thanks for this tutorial. I found this after quite a search. I want to start by saying that I'm quite new to docker, php, but I've been taking a very good course on it all. Now I've followed through and I think I can say that my vscode is connected to docker and all. But perhaps cause I don't really know what breakpoints are or something. But when I set a breakpoint and refresh the man application entrance file (public/index.php in my case) the breakpoint changes to "unverified breakpoint". I see the same msg on the debug console log. I don't know where to begin. Pls any hint that can help? Thanks alot

Zubbee
Автор

Thanks. Needed to remap local volume: serverSourceRoot and localSourceRoot to find the files during xdebug session
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9004,
"hostname":"0.0.0.0",
"pathMappings":{
"/":"${workspaceRoot}/"
},
"serverSourceRoot": "/var/www/html",
"localSourceRoot": "${workspaceRoot}/",
"log": true
},

truelyfine
visit shbcf.ru