Docker on MacOS: Xdebug for PhpStorm
orphan
Docker on MacOS: Xdebug for PhpStorm
Use this guide to debug Devilbox projects with PhpStorm 2024.3 or 2025.1, PHP 8.3 or 8.4, Xdebug 3, and Docker Desktop on macOS.
Prerequisites
- A running Devilbox checkout on macOS.
- Docker Desktop for Mac.
- PhpStorm 2024.3 or 2025.1.
- A project below
./data/wwwor the directory configured for HTTPD data.
See also: Xdebug options explained.
Assumptions
| Setting | Example |
|---|---|
| Devilbox directory | /Users/cytopia/repo/devilbox |
| Local project path | /Users/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
/Users/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 /Users/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.logRestart Devilbox
Restart the PHP container so the new ini file is loaded:
host> cd /Users/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.