I will setup a very simple php page and debug it using xdebug and PhpStorm.
Source files can be found here:
https://github.com/ikknd/docker-study in folder recipe-09
Execute this command from docker folder to build image:
docker build -t php-xdebug-custom -f Dockerfile .
Here I use "
php-xdebug-custom
" image instead of "php:7.2-fpm
"File -> Settings -> Languages & Frameworks -> PHP -> Servers
Add a new server using + icon, and configure like on the following screenshot:
Make sure to check "Use path mappings" and map php folder to "
/var/www/myapp
"Run -> Edit configurations -> PHP Remote Debug
Add a new configuration and give it values like on the following screenshot:
docker-compose up -d
If I now try
myapp.loc/
in browser, I will see results from index.php file.I can set a breakpoint, start listening for connections in PhpStorm debug panel, and reload page.
Happy debugging!