forum/docs/xdebug.md
Kévin Dunglas 17a02310d5
feat: add native Xdebug support (#271)
* feat: add native Xdebug support

* cleanup

* fix review

* fix review

* Improve docs

* some more improvements

* remove useless env var
2022-08-04 14:47:59 +02:00

1.6 KiB

Using Xdebug

The default development image is shipped with Xdebug, a popular debugger and profiler for PHP.

Because it has a significant performance overhead, the step-by-step debugger is disabled by default. It can be enabled by setting the XDEBUG_MODE environment variable to debug.

On Linux and Mac:

XDEBUG_MODE=debug docker compose up -d

On Windows:

set XDEBUG_MODE=debug&& docker compose up -d&set XDEBUG_MODE=

Debugging with Xdebug and PHPStorm

First, create a PHP debug remote server configuration:

  1. In the Settings/Preferences dialog, go to PHP | Servers
  2. Create a new server:
    • Host: localhost (or the one defined using the SERVER_NAME environment variable)
    • Port: 443
    • Debugger: Xdebug
    • Check Use path mappings
    • Absolute path on the server: /srv/app

You can now use the debugger!

  1. In PHPStorm, open the Run menu and click on Start Listening for PHP Debug Connections
  2. Add the XDEBUG_SESSION=PHPSTORM query parameter to the URL of the page you want to debug, or use other available triggers

Alternatively, you can use the Xdebug extension for your preferred web browser.

Troubleshooting

Inspect the installation with the following command. The Xdebug version should be displayed.

$ docker compose exec php php --version

PHP ...
    with Xdebug v3.1.2 ...