Skip to content

Commit e5ec572

Browse files
committed
Add 'make xdebug' command.
1 parent b2e773f commit e5ec572

File tree

5 files changed

+174
-2
lines changed

5 files changed

+174
-2
lines changed

.vscode/launch.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Listen for Xdebug",
9+
"type": "php",
10+
"request": "launch",
11+
"port": 9003,
12+
"pathMappings": {
13+
"/var/www/drupal": "${workspaceRoot}/codebase",
14+
}
15+
},
16+
{
17+
"name": "Launch currently open script",
18+
"type": "php",
19+
"request": "launch",
20+
"program": "${file}",
21+
"cwd": "${fileDirname}",
22+
"port": 0,
23+
"runtimeArgs": [
24+
"-dxdebug.start_with_request=yes"
25+
],
26+
"env": {
27+
"XDEBUG_MODE": "debug,develop",
28+
"XDEBUG_CONFIG": "client_port=${port}"
29+
}
30+
},
31+
{
32+
"name": "Launch Built-in web server",
33+
"type": "php",
34+
"request": "launch",
35+
"runtimeArgs": [
36+
"-dxdebug.mode=debug",
37+
"-dxdebug.start_with_request=yes",
38+
"-S",
39+
"localhost:0"
40+
],
41+
"program": "",
42+
"cwd": "${workspaceRoot}",
43+
"port": 9003,
44+
"serverReadyAction": {
45+
"pattern": "Development Server \\(http://islandora.traefik.me:([0-9]+)\\) started",
46+
"uriFormat": "http://islandora.traefik.me:%s",
47+
"action": "openExternally"
48+
}
49+
}
50+
]
51+
}

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ TARGET_MAX_CHAR_NUM=20
112112
IS_DRUPAL_PSSWD_FILE_READABLE := $(shell test -r secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD -a -w secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD && echo 1 || echo 0)
113113
CMD := $(shell [ $(IS_DRUPAL_PSSWD_FILE_READABLE) -eq 1 ] && echo 'tee' || echo 'sudo -k tee')
114114

115+
PHP_VERSION=83
115116
LATEST_VERSION := $(shell curl -s https://api.github.com/repos/desandro/masonry/releases/latest | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\1/')
116117

117118
PHP_FPM_PID=/var/run/php-fpm7/php-fpm7.pid
@@ -690,3 +691,36 @@ wait-for-drupal-locally:
690691
echo "Waiting for https://$(DOMAIN) to be available..."; \
691692
sleep 1; \
692693
done
694+
695+
696+
.PHONY: xdebug
697+
## Turn on xdebug.
698+
xdebug: TIMEOUT_VALUE=3600
699+
xdebug:
700+
701+
$(MAKE) set-timeout TIMEOUT_VALUE=3600
702+
sleep 10
703+
docker compose exec -T drupal with-contenv bash -lc "apk add php${PHP_VERSION}-pecl-xdebug"
704+
docker cp scripts/extra/xdebug.ini $$(docker compose ps -q drupal):/etc/php${PHP_VERSION}/conf.d/xdebug.ini
705+
-docker compose exec -T drupal with-contenv bash -lc "chown root:root /etc/php${PHP_VERSION}_/conf.d/xdebug.ini"
706+
docker compose restart drupal
707+
sleep 6
708+
docker compose exec -T drupal with-contenv bash -lc "php -i | grep xdebug"
709+
710+
.phony: set-timeout
711+
## Update all PHP and NGinx timeouts to TIMEOUT_VALUE
712+
set-timeout:
713+
$(SED_DASH_I) 's/NGINX_FASTCGI_READ_TIMEOUT: .*s/NGINX_FASTCGI_READ_TIMEOUT: $(TIMEOUT_VALUE)s/g' docker-compose.yml
714+
$(SED_DASH_I) 's/NGINX_FASTCGI_CONNECT_TIMEOUT: .*s/NGINX_FASTCGI_CONNECT_TIMEOUT: $(TIMEOUT_VALUE)s/g' docker-compose.yml
715+
$(SED_DASH_I) 's/NGINX_FASTCGI_SEND_TIMEOUT: .*s/NGINX_FASTCGI_SEND_TIMEOUT: $(TIMEOUT_VALUE)s/g' docker-compose.yml
716+
$(SED_DASH_I) 's/NGINX_KEEPALIVE_TIMEOUT: .*s/NGINX_KEEPALIVE_TIMEOUT: $(TIMEOUT_VALUE)s/g' docker-compose.yml
717+
$(SED_DASH_I) 's/NGINX_PROXY_CONNECT_TIMEOUT: .*s/NGINX_PROXY_CONNECT_TIMEOUT: $(TIMEOUT_VALUE)s/g' docker-compose.yml
718+
$(SED_DASH_I) 's/NGINX_PROXY_READ_TIMEOUT: .*s/NGINX_PROXY_READ_TIMEOUT: $(TIMEOUT_VALUE)s/g' docker-compose.yml
719+
$(SED_DASH_I) 's/NGINX_PROXY_SEND_TIMEOUT: .*s/NGINX_PROXY_SEND_TIMEOUT: $(TIMEOUT_VALUE)s/g' docker-compose.yml
720+
$(SED_DASH_I) 's/NGINX_SEND_TIMEOUT: .*s/NGINX_SEND_TIMEOUT: $(TIMEOUT_VALUE)s/g' docker-compose.yml
721+
$(SED_DASH_I) 's/PHP_DEFAULT_SOCKET_TIMEOUT: ".*"/PHP_DEFAULT_SOCKET_TIMEOUT: "$(TIMEOUT_VALUE)"/g' docker-compose.yml
722+
$(SED_DASH_I) 's/PHP_MAX_EXECUTION_TIME: ".*"/PHP_MAX_EXECUTION_TIME: "$(TIMEOUT_VALUE)"/g' docker-compose.yml
723+
$(SED_DASH_I) 's/PHP_MAX_INPUT_TIME: ".*"/PHP_MAX_INPUT_TIME: "$(TIMEOUT_VALUE)"/g' docker-compose.yml
724+
$(SED_DASH_I) 's/PHP_PROCESS_CONTROL_TIMEOUT: ".*"/PHP_PROCESS_CONTROL_TIMEOUT: "$(TIMEOUT_VALUE)"/g' docker-compose.yml
725+
$(SED_DASH_I) 's/PHP_REQUEST_TERMINATE_TIMEOUT: ".*"/PHP_REQUEST_TERMINATE_TIMEOUT: "$(TIMEOUT_VALUE)"/g' docker-compose.yml
726+
docker compose up -d --force-recreate --remove-orphans

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ To enable using secrets prior to running the `make` commands, copy sample.env
225225
to .env. Set `USE_SECRETS=true` in your .env file. Make a copy of the files in
226226
/secrets/template/ to /secrets/live/.
227227

228-
To enable using secrets after run `make local` or `make up`, set
228+
To enable using secrets after run `make local` or `make up`, set
229229
`USE_SECRETS=true` in your .env file. When you run `make docker-compose.yml`, a
230230
large block of `secrets` will be added at the top of your `docker-compose.yml`
231231
file.
@@ -259,6 +259,26 @@ Setting admin password now
259259

260260
```
261261

262+
### Enable XDebug
263+
264+
```shell
265+
make xdebug
266+
```
267+
268+
This will download and enable the [XDebug](https://xdebug.org)
269+
PHP debugger.
270+
271+
It also changes all of the PHP and Nginx timeouts so your
272+
debugging session doesn't get shut down while you're working.
273+
274+
Bringing ISLE down and back up will disable the debugger again.
275+
276+
You can put custom XDebug config settings in scripts/extra/xdebug.ini
277+
278+
See the documentation for your code editor for further
279+
details on how to debug PHP applications.
280+
Specifically the 'Listen for XDebug' command.
281+
262282
## Services
263283

264284
Islandora is composed of many different services, this project has split these
@@ -386,7 +406,7 @@ lowercasename:
386406
echo "first line in command needs to be indented. There are exceptions to this, review functions in the Makefile for examples of these exceptions."
387407
```
388408

389-
NOTE: A target you add in the custom.Makefile will not override an existing target with the same label in this repository's defautl Makefile.
409+
NOTE: A target you add in the custom.Makefile will not override an existing target with the same label in this repository's defautl Makefile.
390410

391411
Running the new `custom.Makefile` commands are exactly the same as running any other Makefile command. Just run `make` and the function's name.
392412
```bash

scripts/extra/launch.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Listen for Xdebug",
9+
"type": "php",
10+
"request": "launch",
11+
"port": 9003,
12+
"pathMappings": {
13+
"/var/www/drupal": "${workspaceRoot}/codebase",
14+
}
15+
},
16+
{
17+
"name": "Launch Chrome",
18+
"request": "launch",
19+
"type": "chrome",
20+
"url": "https://islandora.traefik.me",
21+
"webRoot": "${workspaceFolder}/codebase/web"
22+
},
23+
{
24+
"name": "Launch currently open script",
25+
"type": "php",
26+
"request": "launch",
27+
"program": "${file}",
28+
"cwd": "${fileDirname}",
29+
"port": 0,
30+
"runtimeArgs": [
31+
"-dxdebug.start_with_request=yes"
32+
],
33+
"env": {
34+
"XDEBUG_MODE": "debug,develop",
35+
"XDEBUG_CONFIG": "client_port=${port}"
36+
}
37+
},
38+
{
39+
"name": "Launch Built-in web server",
40+
"type": "php",
41+
"request": "launch",
42+
"runtimeArgs": [
43+
"-dxdebug.mode=debug",
44+
"-dxdebug.start_with_request=yes",
45+
"-S",
46+
"localhost:0"
47+
],
48+
"program": "",
49+
"cwd": "${workspaceRoot}",
50+
"port": 9003,
51+
"serverReadyAction": {
52+
"pattern": "Development Server \\(http://islandora.traefik.me:([0-9]+)\\) started",
53+
"uriFormat": "http://islandora.traefik.me:%s",
54+
"action": "openExternally"
55+
}
56+
}
57+
]
58+
}

scripts/extra/xdebug.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
zend_extension=xdebug.so
2+
xdebug.mode=debug
3+
xdebug.start_with_request=true
4+
xdebug.cli_color=1
5+
xdebug.discover_client_host=0
6+
xdebug.client_host=host.docker.internal
7+
xdebug.max_nesting_level=512
8+
xdebug.log_level = 0
9+
xdebug.log=/var/log/xdebug.log

0 commit comments

Comments
 (0)