Skip to content

Commit d4432f2

Browse files
authored
📝 update xdebug documentation (#136)
1 parent ec5a0d2 commit d4432f2

4 files changed

Lines changed: 46 additions & 33 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ services:
7474

7575
- WEB_DOCUMENT_ROOT=/app/public
7676
- XDEBUG_CLIENT_HOST=${XDEBUG_CLIENT_HOST:-}
77-
- XDEBUG_CLIENT_PORT=${XDEBUG_CLIENT_PORT:-9000}
7877
- php.xdebug.idekey=${XDEBUG_IDEKEY:-PHPSTORM}
78+
- PHP_IDE_CONFIG=${XDEBUG_IDEKEY:-"serverName=_"}
7979

8080
# Project Env vars (enable what you need)
8181
# - APP_ENV=development_docker

docs/images/xdebug-listen.png

7.84 KB
Loading
125 KB
Loading

docs/xdebug.md

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,63 @@
11
# Xdebug
22

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]
1019

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
1321

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)
1525

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
1735

1836
````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=_"
2539
````
2640

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)
2845
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.
3047
````
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" ...
3549
````
3650

37-
## WEB:
51+
## Problem Solving:
3852

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:
4154

42-
### Listening for PHP Debug Sessions:
55+
`touch xdebug.log`
4356

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
4658
````
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
5060
````
61+
62+
[xdebug-setup]: ./images/xdebug-phpstorm-server-config.png
63+
[xdebug-listen]: ./images/xdebug-listen.png

0 commit comments

Comments
 (0)