Docker on Linux: Xdebug for PhpStorm
orphan
Docker on Linux: Xdebug for PhpStorm
Use this guide to debug Devilbox projects with PhpStorm 2024.3 or 2025.1, PHP 8.3 or 8.4, and Xdebug 3 on Docker Engine for Linux.
Prerequisites
- A running Devilbox checkout on Linux.
- PhpStorm 2024.3 or 2025.1.
- A project below
./data/wwwor the directory configured for HTTPD data. - Familiarity with custom PHP ini files in Devilbox.
See also: Xdebug options explained.
Assumptions
| Setting | Example |
|---|---|
| Devilbox directory | /home/cytopia/repo/devilbox |
| Local project path | /home/cytopia/repo/devilbox/data/www/myapp |
| Container project path | /shared/httpd/myapp |
| PHP version | 8.4 |
| Xdebug client host | host.docker.internal |
| Xdebug client port | 9003 |
Adjust the local project path if your HTTPD_DOCROOT_DIR or project name
differs. The container-side HTTPD root remains below /shared/httpd.
Configure PhpStorm
- Open Settings | PHP | Debug and set the Xdebug debug port to
9003. - Open Settings | PHP | Servers and create a server named after your
local Devilbox vhost, for example
myapp.lvh.me. - Set the host to your vhost, keep the debugger as Xdebug, and enable path mappings.
- Map
/home/cytopia/repo/devilbox/data/www/myappto/shared/httpd/myapp. - Start listening with Run | Start Listening for PHP Debug Connections.
Configure Xdebug 3
Create cfg/php-ini-8.4/xdebug.ini in your Devilbox checkout. Use
cfg/php-ini-8.3/xdebug.ini if your project runs on PHP 8.3.
host> cd /home/cytopia/repo/devilboxhost> vi cfg/php-ini-8.4/xdebug.iniAdd the current Xdebug 3 settings:
zend_extension=xdebug.so
xdebug.mode=debugxdebug.client_host=host.docker.internalxdebug.client_port=9003xdebug.start_with_request=yesxdebug.idekey=PHPSTORM
; Optional, useful while testing connectionsxdebug.log=/var/log/php/xdebug.logIf host.docker.internal is not available in your custom Linux setup,
replace it with the host IP address reachable from the PHP container.
Restart Devilbox
Restart the PHP container so the new ini file is loaded:
host> cd /home/cytopia/repo/devilboxhost> docker-compose stop phphost> docker-compose rm -f phphost> docker-compose up php httpd bindOpen a page in the browser with a breakpoint set in PhpStorm. PhpStorm
should receive the DBGp connection on port 9003.