Debugging Web Applications In PHPStorm With Xdebug And Docker
Overview
How to debug a PHP web application in PHPStorm using Docker and XDebug. [1] [2]
PHP Configuration
Preferences > Language & Frameworks > PHP > Servers
Click the "plus" icon to create a new server.
- Name: docker
- Host: localhost
- Port: 80
- Debugger: Xdebug
- Use path mappings:
checked
Then under path mappings create associations between project files and their respective locations in the Docker container, e.g.:
The host and port reference host and port within the Docker container. This applies to the path mappings as well.
The container's HTML root is /var/www/html. This path may or may not exist on the local file system, but that doesn't impact anything here.
Two project file directories cannot point to the same path on the server (e.g. bfhhand_web and common_lib can't coexist in the same root directory as they do on production.)
See also
- ↑ Getting xDebug to Work - Servers For Hackers
- ↑ Debug your PHP in Docker with Intellij/PHPStorm and Xdebug - GitHub Gist