This document describes how to configure debugging of Spryker in Docker.
Xdebug is the default debugging tool for Spryker in Docker. To enable Xdebug, run the command:
docker/sdk {run|start|up} -x
This section describes how to configure Phpstorm to be used with Xdebug.
Install the required software:
- Install PhpStorm, Early Access Program preferred. You can download PHPStorm through the Jetbrains Toolbox.
- Install Xdebug.
- Optional: install the Xdebug browser extension. In the extension settings, for IDE key, enter
PHPSTORM
.
To configure Xdebug in PhpStorm:
-
Go to Preferences > PHP > Debug.
-
In the Xdebug section:
- Depending on your requirements, for Debug port, enter one or more ports.
For example, to support Xdebug 2 and 3, enter
9000,9003
. - Select the Can accept external connections checkbox.
- Clear the Force break at first line when no path mapping specified and Force break at first line when a script is outside the project checkboxes.
- Depending on your requirements, for Debug port, enter one or more ports.
For example, to support Xdebug 2 and 3, enter
-
In the External connections section:
- For Max. simultaneous connection, select 5.
- Clear the Ignore external connections through unregistered server configurations and Break at first line in PHP scripts checkboxes.
To configure servers:
-
Go to Preferences > PHP > Servers.
-
Add a server:
when A breakpoint does not work.
then
- In PhpStorm, go to Preferences > PHP > Debug.
- Select the Break at first line in PHP scripts checkbox.
- Rerun or refresh your application.
The app should break at the
index.php
and open a debugger pane in the IDE: - Re-try your breakpoints.
This section describes how to configure Visual Studio Code (VSCode) to be used with Xdebug.
Install the required software:
- Install VScode, the Insiders version preferred.
- Install Xdebug.
- Install PHP Debug Extension.
Set up a new Launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"runtimeExecutable": "/absolute/path/php/bin",
"pathMappings": {
"/data": "/local/absolute/path",
},
"log": true,
"xdebugSettings": {
"max_data": 65535,
"show_hidden": 1,
"max_children": 100,
"max_depth": 5
}
},
]
}
The default Zed Request timeout is 60 seconds. Debugging requests often take more than 60 seconds to complete. In this case, a browser stops the connection.
To avoid Zed Request timeouts, adjust your configuration as follows:
$config[ZedRequestConstants::CLIENT_OPTIONS] = [
'timeout' => 300,
];
300 seconds should suit most cases, but you can increase it or even make it unlimited by defining the value as 0
.
:::(Warning) (Unlimited timeout) If you set unlimited timeout, this affects all Zed Requests, not only debugging ones. :::
There are several ways to switch to the debugging mode:
- To debug a web application, pass the
XDEBUG_SESSION
cookie with a string value. If you are using the Xdebug helper browser extension, in the extension menu, select debug. - To run all applications in the debugging mode, run
docker/sdk {run|start|up} -x
. - To debug a console command in cli, run it with the
-x
option.
This section describes how to debug with Xdebug.
To debug an application:
-
Open the application in a browser.
-
Navigate to the action you have configured the breakpoint for in step 1. The debugging process should be running in the IDE:
To debug a console command or a test in a debugging mode, run it with the -x
option.
Find several examples below:
docker/sdk cli -x
docker/sdk cli -x console queue:worker:start
docker/sdk console -x queue:worker:start
docker/sdk testing -x codecept run -codeception.yml