Skip to content

Commit b2e2e44

Browse files
authored
Merge pull request #164 from usabilla/agustin/GFPPLAT-473/xdebug-3-exploration
Upgrade Xdebug to v3
2 parents d50a670 + d41c39b commit b2e2e44

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,34 @@ Both are enabled via the helper script, by running
476476
$ docker-php-dev-mode config
477477
```
478478

479+
##### Setting up Xdebug
480+
481+
Xdebug 3 comes with new mechanism to enable it's functionalities. The most notable, is the introduction of the
482+
`xdebug.mode` setting, which controls which features are enabled. It can be specified via `.ini` files or by using the
483+
environment variable `XDEBUG_MODE`. To learn more about the different modes in which Xdebug can be configured, please
484+
refer to the [Xdebug settings guide](https://xdebug.org/docs/all_settings#mode).
485+
486+
##### Notable changes from Xdebug 2
487+
488+
With the introduction of the Xdebug mode in the v3 release, it is now mandatory to specify either `xdebug.mode=coverage` setting in .ini
489+
file, or `XDEBUG_MODE=coverage` as environment variable, to use the code coverage analysis features. This impacts tools
490+
like mutation tests.
491+
492+
We recommend setting the XDEBUG_MODE when booting up a new container. Here's an example on how it could look like:
493+
494+
```shell
495+
docker run -it \
496+
-e XDEBUG_MODE=coverage \
497+
-v "<HOST_PATH>:<CONTAINER_PATH>" \
498+
usabillabv/php:7.4-cli-alpine3.12-dev \
499+
vendor/bin/infection --test-framework-options='--testsuite=unit' -s --threads=12 --min-msi=100 --min-covered-msi=100
500+
```
501+
502+
Another notable change, is the Xdebug port change. The default port is now `9003` instead of `9000`. Check your IDE
503+
settings to confirm the correct port is specified.
504+
505+
For the full upgrade guide, please refer to the [official upgrade guide](https://xdebug.org/docs/upgrade_guide).
506+
479507
## Prometheus Exporter
480508

481509
In order to monitor applications many systems implement Prometheus to expose metrics, one challenge specially in PHP is how to expose those to Prometheus without having to, either implement an endpoint in our application, or add HTTP and an endpoint for non-interactive containers.

src/php/conf/available/xdebug.ini

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
xdebug.default_enable=0
2-
xdebug.remote_enable=1
3-
xdebug.remote_host=host.docker.internal
4-
xdebug.remote_connect_back=0
5-
xdebug.profiler_enable_trigger=1
1+
; Xdebug 2 to 3 Upgrade Guide: https://3.xdebug.org/docs/upgrade_guide
2+
;
3+
; Full list of settings and their defaults at: https://xdebug.org/docs/all_settings
4+
5+
xdebug.mode=develop
6+
xdebug.client_host=host.docker.internal

src/php/utils/docker/docker-php-dev-mode

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ case "$1" in
2929
exit 1
3030
fi
3131

32-
pecl install xdebug-2.9.8
32+
pecl install xdebug-stable
3333
docker-php-ext-enable xdebug
3434
apk del $apkDel
3535

0 commit comments

Comments
 (0)