Skip to content

Commit fcff96b

Browse files
dunglasmaxhelias
authored andcommitted
docs(xdebug): fix host on Linux
1 parent 8a9b8c8 commit fcff96b

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

docs/xdebug.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Installing Xdebug
22

3-
The default Docker stack is shipped without a Xdebug stage.
4-
It's easy though to add [Xdebug](https://xdebug.org/) to your project, for development purposes such as debugging tests or API requests remotely.
3+
The default Docker stack is shipped without [Xdebug](https://xdebug.org/),
4+
a popular debugger and profiler for PHP.
5+
It's easy, though, to add it to your project.
56

67
## Add a Debug Stage to the Dockerfile
78

@@ -12,7 +13,7 @@ it's recommended to add a custom stage to the end of the `Dockerfile`.
1213
# Dockerfile
1314
FROM symfony_php AS symfony_php_debug
1415

15-
ARG XDEBUG_VERSION=3.0.4
16+
ARG XDEBUG_VERSION=3.1.2
1617
RUN set -eux; \
1718
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
1819
pecl install xdebug-$XDEBUG_VERSION; \
@@ -25,7 +26,7 @@ RUN set -eux; \
2526
Using an [override](https://docs.docker.com/compose/reference/overview/#specifying-multiple-compose-files) file named `docker-compose.debug.yml` ensures that the production
2627
configuration remains untouched.
2728

28-
As example, an override could look like this:
29+
As an example, an override could look like this:
2930

3031
```yaml
3132
# docker-compose.debug.yml
@@ -47,9 +48,12 @@ services:
4748
# This should correspond to the server declared in PHPStorm `Preferences | Languages & Frameworks | PHP | Servers`
4849
# Then PHPStorm will use the corresponding path mappings
4950
PHP_IDE_CONFIG: serverName=symfony
51+
extra_hosts:
52+
# Ensure that host.docker.internal is correctly defined on Linux
53+
- host.docker.internal:host-gateway
5054
```
5155
52-
Build your image with your fresh new xdebug configuration:
56+
Build your image with your fresh new XDebug configuration:
5357
5458
```console
5559
docker-compose -f docker-compose.yml -f docker-compose.debug.yml build
@@ -65,29 +69,29 @@ docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d
6569

6670
You can use the **Xdebug extension** for [Chrome](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc) or [Firefox](https://addons.mozilla.org/fr/firefox/addon/xdebug-helper-for-firefox/) if you want to debug on the browser (don't forget to configure it).
6771

68-
If you don't want to use it, just add on your request this query param: `XDEBUG_SESSION=PHPSTORM`.
72+
If you don't want to use it, add on your request this query param: `XDEBUG_SESSION=PHPSTORM`.
6973

70-
On PHPStorm, you just have to click on the button `Start Listening for PHP Debug Connections` on the `Run` menu.
74+
On PHPStorm, click on `Start Listening for PHP Debug Connections` in the `Run` menu.
7175

7276
Otherwise, you can create a [PHP Remote Debug](https://www.jetbrains.com/help/phpstorm/creating-a-php-debug-server-configuration.html) configuration with the following parameters:
7377

7478
* Server:
75-
* Name: **symfony** (must be the same as defined in *PHP_IDE_CONFIG*)
76-
* Host: **https://localhost** (or the one defined with *SERVER_NAME*)
77-
* Port: **443**
78-
* Debugger: **Xdebug**
79-
* Absolute path on the server: **/srv/app**
80-
* IDE key: **PHPSTORM**
79+
* Name: `symfony` (must be the same as defined in `PHP_IDE_CONFIG`)
80+
* Host: `https://localhost` (or the one defined with `SERVER_NAME`)
81+
* Port: `443`
82+
* Debugger: `Xdebug`
83+
* Absolute path on the server: `/srv/app`
84+
* IDE key: `PHPSTORM`
8185

8286
You can now use the debugger.
8387

8488
## Troubleshooting
8589

86-
Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.
90+
Inspect the installation with the following command. The Xdebug version should be displayed.
8791

8892
```console
8993
$ docker-compose exec php php --version
9094

9195
PHP ...
92-
with Xdebug v3.0.4 ...
96+
with Xdebug v3.1.2 ...
9397
```

0 commit comments

Comments
 (0)