|
1 | 1 | # Xdebug |
2 | 2 |
|
3 | | -You can set the default value for the PHP_DEBUGGER in your `.env` file: |
4 | | -````env |
5 | | -# xdebug 3: |
6 | | -XDEBUG_CLIENT_HOST=10.50.1.223 |
7 | | -# xdebug 2: |
8 | | -XDEBUG_REMOTE_HOST=10.50.1.223 |
9 | | -```` |
| 3 | +## Setup in PhpStorm |
| 4 | + |
| 5 | +You need to create a PHP->Server Config. |
| 6 | +chose a name you like or fallback to `_`. |
| 7 | +Add the Host `_` it is important that you use this exact Host. only with this Setting it will work in the newest PhpStorm version. |
| 8 | +Setup the path mapping like the marked line in the picture: `project files -> /app`. |
| 9 | + |
| 10 | +![PhpStorm Settings Php Servers][xdebug-setup] |
| 11 | + |
| 12 | +Read more: [Creating a PHP Debug Server](https://www.jetbrains.com/help/phpstorm/creating-a-php-debug-server-configuration.html) |
| 13 | + |
| 14 | +## Usage in PhpStorm |
| 15 | + |
| 16 | +You can use the listening Feature in the Top of PhpStorm |
| 17 | + |
| 18 | +![Listen for Debugging Connections][xdebug-listen] |
10 | 19 |
|
11 | | -`XDEBUG_CLIENT_HOST` is the ip-address of your IDE <br /> |
12 | | -Information on how to set up xdebug with PHPStorm is here: [Creating a PHP Debug Server](https://www.jetbrains.com/help/phpstorm/creating-a-php-debug-server-configuration.html) |
| 20 | +## start xdebug |
13 | 21 |
|
14 | | -hint: if `PHP_DEBUGGER` is set to `xdebug`, then the xh-profiler won't profile anything |
| 22 | +By default xdebug is disabled in the container. |
| 23 | +You can enable it by running `xdebug-enable` inside the container. (will disable xh-profiler) |
| 24 | +You can disable it by running `xdebug-disable` inside the container. (will enable xh-profiler again) |
15 | 25 |
|
16 | | -## enable and disable xdebug in running container: |
| 26 | +it will also restart the `fpm` processes |
| 27 | + |
| 28 | +### Web Debugging |
| 29 | + |
| 30 | +We recommend the usage of an enable-disable tool like [Xdebug helper](https://chrome.google.com/webstore/detail/debug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc) |
| 31 | +> hint: using the xdebug-helper also works for the xh-profiler, see [PHP Profiling](profiling.md) for more information |
| 32 | +
|
| 33 | + |
| 34 | +### Cli Debugging |
17 | 35 |
|
18 | 36 | ````bash |
19 | | -# enables xdebug and restarts fpm (hint: this also disables the xh-profiler) |
20 | | -xdebug-enable |
21 | | -# disable xdebug and restarts fpm (hint: this also enables the xh-profiler) |
22 | | -xdebug-disable |
23 | | -# the following alias toggles xdebug and xh-profiler |
24 | | -xdebug-toggle |
| 37 | +export XDEBUG_CLIENT_HOST=172.23.96.1 |
| 38 | +export PHP_IDE_CONFIG="serverName=_" |
25 | 39 | ```` |
26 | 40 |
|
27 | | -# With xdebug enabled you need to activate xdebug on script run. |
| 41 | +`XDEBUG_CLIENT_HOST` is the ip-address of your IDE |
| 42 | +`serverName` is the Host input field in PhpStorm PHP->Server setting |
| 43 | + |
| 44 | +> you can Also put these in the .env of the project. (if corresponding the 2 lines are in the docker-compose.yml) |
28 | 45 |
|
29 | | -## CLI: run any php script with this prefixed: |
| 46 | +Than if you run your command that you want to debug you should add `XDEBUG_CONFIG="client_enable=1"` in front of it. |
30 | 47 | ```` |
31 | | -# xdebug 3: |
32 | | -PHP_IDE_CONFIG="serverName=Unnamed" XDEBUG_CONFIG="client_enable=1" php #... |
33 | | -# xdebug 2: |
34 | | -PHP_IDE_CONFIG="serverName=Unnamed" XDEBUG_CONFIG="remote_enable=1" php #... |
| 48 | +XDEBUG_CONFIG="client_enable=1" ... |
35 | 49 | ```` |
36 | 50 |
|
37 | | -## WEB: |
| 51 | +## Problem Solving: |
38 | 52 |
|
39 | | -We recommend the usage of an enable-disable tool like [Xdebug helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc) |
40 | | -<br />hint: using the xdebug-helper also works for the xh-profiler, see [PHP Profiling](profiling.md) for more information |
| 53 | +you can enable the xdebug log like this: |
41 | 54 |
|
42 | | -### Listening for PHP Debug Sessions: |
| 55 | +`touch xdebug.log` |
43 | 56 |
|
44 | | -If you want to use the "Start Listening for PHP Debug Connections" Button in PHPStorm, you can set these ENV variables: |
45 | | -Where Unnamed is the name of the server config in PHPStorm. |
| 57 | +add this to your docker-compose.yml |
46 | 58 | ```` |
47 | | - - php.xdebug.client_enable=1 |
48 | | - - php.xdebug.client_autostart=1 |
49 | | - - PHP_IDE_CONFIG=serverName=Unnamed |
| 59 | + - php.xdebug.log=/app/xdebug.log |
50 | 60 | ```` |
| 61 | + |
| 62 | +[xdebug-setup]: ./images/xdebug-phpstorm-server-config.png |
| 63 | +[xdebug-listen]: ./images/xdebug-listen.png |
0 commit comments