Skip to content

Commit 9655ec9

Browse files
authored
Add notes for XDebug usage to README.md - Fixes #118 (#119)
* Add notes for XDebug usage to README.md - Fixes #118 * Refine notes about XDebug usage in README.md
1 parent a32b321 commit 9655ec9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,49 @@ You can change the configuration of the docker images by setting various environ
136136
| `MOODLE_DOCKER_SELENIUM_VNC_PORT` | no | any integer value (or bind_ip:integer)| not set | If set, the selenium node will expose a vnc session on the port specified. Similar to MOODLE_DOCKER_WEB_PORT, you can optionally define the host IP to bind to. If you just set the port, VNC binds to 127.0.0.1 |
137137
| `MOODLE_APP_VERSION` | no | next, latest, or an app version number| not set | If set will start an instance of the Mmodle app if the chrome browser is selected |
138138

139+
## Using XDebug for live debugging
140+
141+
The XDebug PHP Extension is not included in this setup and there are reasons not to include it by default.
142+
143+
However, if you want to work with XDebug, especially for live debugging, you can add XDebug to a running webserver container easily:
144+
145+
```
146+
# Install XDebug extension with PECL
147+
moodle-docker-compose exec webserver pecl install xdebug
148+
149+
# Set some wise setting for live debugging - change this as needed
150+
read -r -d '' conf <<'EOF'
151+
; Settings for Xdebug Docker configuration
152+
xdebug.coverage_enable = 0
153+
xdebug.default_enable = 0
154+
xdebug.cli_color = 2
155+
xdebug.file_link_format = phpstorm://open?%f:%l
156+
xdebug.idekey = PHPSTORM
157+
xdebug.remote_enable = 1
158+
xdebug.remote_autostart = 1
159+
xdebug.remote_host = host.docker.internal
160+
EOF
161+
moodle-docker-compose exec webserver bash -c "echo '$conf' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
162+
163+
# Enable XDebug extension in Apache
164+
moodle-docker-compose exec webserver docker-php-ext-enable xdebug
165+
```
166+
167+
While setting these XDebug settings depending on your local need, please take special care of the value of `xdebug.remote_host` which is needed to connect from the container to the host. The given value `host.docker.internal` is a special DNS name for this purpose within Docker for Windows and Docker for Mac. If you are running on another Docker environment, you might want to try the value `localhost` instead or even set the hostname/IP of the host directly.
168+
169+
After these commands, XDebug ist enabled and ready to be used in the webserver container.
170+
If you want to disable and re-enable XDebug during the lifetime of the webserver container, you can achieve this with these additional commands:
171+
172+
```
173+
# Disable XDebug extension in Apache and restart the webserver container
174+
moodle-docker-compose exec webserver sed -i 's/^zend_extension=/; zend_extension=/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
175+
moodle-docker-compose restart webserver
176+
177+
# Enable XDebug extension in Apache and restart the webserver container
178+
moodle-docker-compose exec webserver sed -i 's/^; zend_extension=/zend_extension=/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
179+
moodle-docker-compose restart webserver
180+
```
181+
139182
## Advanced usage
140183

141184
As can be seen in [bin/moodle-docker-compose](https://github.com/moodlehq/moodle-docker/blob/master/bin/moodle-docker-compose),

0 commit comments

Comments
 (0)