Docker on Linux: Xdebug for Sublime Text 3
orphan
Docker on Linux: Xdebug for Sublime Text
Use this guide to debug Devilbox projects with Sublime Text 4, the
xdebug-client package, PHP 8.3 or 8.4, and Xdebug 3 on Docker Engine
for Linux.
Prerequisites
- A running Devilbox checkout on Linux.
- Sublime Text 4 with Package Control installed.
- The
xdebug-clientpackage installed from Package Control. - A project below
./data/wwwor the directory configured for HTTPD data.
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 |
The local project path is where Sublime opens your files. The container path is what PHP reports to the debug client.
Configure Sublime Text 4
- Install
xdebug-clientwith Package Control. - Open Preferences | Package Settings | Xdebug Client | Settings.
- Configure the listener and path mapping for your project.
{ "path_mapping": { "/shared/httpd/myapp": "/home/cytopia/repo/devilbox/data/www/myapp" }, "url": "http://myapp.lvh.me/", "ide_key": "sublime.xdebug", "host": "0.0.0.0", "port": 9003}Start the Sublime debug listener before loading the page in your browser.
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=sublime.xdebug
; 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 your project URL with the Sublime listener active. Sublime should stop at breakpoints once the path mapping matches the container path.