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=
First, create a PHP debug remote server configuration:
- In the
Settings/Preferences
dialog, go toPHP | Servers
- Create a new server:
- Name:
symfony
(or whatever you want to use for the variablePHP_IDE_CONFIG
) - Host:
localhost
(or the one defined using theSERVER_NAME
environment variable) - Port:
443
- Debugger:
Xdebug
- Check
Use path mappings
- Absolute path on the server:
/srv/app
- Name:
You can now use the debugger!
-
In PHPStorm, open the
Run
menu and click onStart Listening for PHP Debug Connections
-
Add the
XDEBUG_SESSION=PHPSTORM
query parameter to the URL of the page you want to debug, or use other available triggersAlternatively, you can use the Xdebug extension for your preferred web browser.
-
On command line, we might need to tell PHPStorm which path mapping configuration should be used, set the value of the PHP_IDE_CONFIG environment variable to
serverName=symfony
, wheresymfony
is the name of the debug server configured higher.Example:
XDEBUG_SESSION=1 PHP_IDE_CONFIG="serverName=symfony" php bin/console ...
Inspect the installation with the following command. The Xdebug version should be displayed.
$ docker compose exec php php --version
PHP ...
with Xdebug v3.x.x ...