Skip to content
This repository was archived by the owner on Jun 25, 2024. It is now read-only.

Commit 0ef8a4a

Browse files
authored
Merge pull request #96 from silinternational/feature/remote-debug
install xdebug for remote debugging
2 parents 58c25a4 + ab7b7a3 commit 0ef8a4a

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,28 @@ Translations are categorized by page in definition files located in the `diction
232232
Localization is affected by the configuration setting `language.available`. Only language codes found in this property will be utilized.
233233
For example, if a translation is provided in Afrikaans for this module, the configuration must be adjusted to make 'af' an available
234234
language. If that's not done, the translation function will not utilize the translations even if provided.
235+
236+
### Debugging
237+
238+
Xdebug can be enabled by doing the following:
239+
240+
1. Define `REMOTE_DEBUG_IP` in `local.env`. This should be the IP address of your development machine, i.e. the one that
241+
is running your IDE. If you're using Linux as your Docker host, you can use 172.17.0.1 here.
242+
2. Map run-debug.sh into the container you wish to debug. For example:
243+
```yaml
244+
volumes:
245+
- ./development/run-debug.sh:/data/run.sh
246+
```
247+
3. Enable debugging in your IDE. See the next section for PhpStorm setup.
248+
249+
## Configuring PhpStorm for remote debugging
250+
251+
In PhpStorm go to: Preferences > PHP > Debug > DBGp Proxy and set the following settings:
252+
- Host: (your IP address or hostname)
253+
- Port: 9000
254+
255+
Set path mappings in: Preferences > PHP > Servers
256+
- Add a server and map the project folder to '/data/vendor/simplesamlphp/simplesamlphp/modules/material'
257+
- Map other directories as needed. PhpStorm should prompt when an unrecognized path is encountered.
258+
259+
Then start listening by clicking the "listen" button on the PhpStorm toolbar.

development/run-debug.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
# establish a signal handler to catch the SIGTERM from a 'docker stop'
6+
# reference: https://medium.com/@gchudnov/trapping-signals-in-docker-containers-7a57fdda7d86
7+
term_handler() {
8+
apache2ctl stop
9+
exit 143; # 128 + 15 -- SIGTERM
10+
}
11+
trap 'kill ${!}; term_handler' SIGTERM
12+
13+
export XDEBUG_CONFIG="remote_enable=1 remote_host="$REMOTE_DEBUG_IP
14+
15+
apt-get update
16+
apt-get install php-xdebug
17+
18+
cd /data
19+
20+
# Send info about this image's O/S and PHP version to our logs.
21+
cat /etc/*release | grep PRETTY
22+
php -v | head -n 1
23+
24+
apache2ctl -k start -D FOREGROUND
25+
26+
# endless loop with a wait is needed for the trap to work
27+
while true
28+
do
29+
tail -f /dev/null & wait ${!}
30+
done

local.env.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ MFA_U2F_appId=
1010
### Optional ENV vars ###
1111
LOGENTRIES_KEY=
1212
COMPOSER_AUTH=
13+
14+
REMOTE_DEBUG_IP=

0 commit comments

Comments
 (0)