Skip to content

Commit d7866cc

Browse files
committed
Install xdebug and xhprof as standard
This also adds a new PHP_EXTENSION-[name]=1 environment variable optino to call docker-php-ext-enable on start.
1 parent b68b255 commit d7866cc

File tree

5 files changed

+95
-1
lines changed

5 files changed

+95
-1
lines changed

.github/workflows/test_buildx_and_publish.yml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
-e PHP_INI-apc.enable_cli=0 \
3333
-e PHP_INI-pcov.enabled=1 \
3434
-e PHP_INI-upload_max_filesize=20M \
35+
-e PHP_EXTENSION_xhprof=1 \
3536
moodle-php-apache
3637
docker exec test0 php /var/www/html/test.php
3738
docker exec test0 php /var/www/html/check-ini.php

README.md

+68
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ $ docker run --name web0 -p 8080:80 -v $PWD:/var/www/html moodlehq/moodle-php-a
4040
* Verified by [automated tests](https://travis-ci.com/moodlehq/moodle-php-apache).
4141
* Autobuilt from GHA, on push.
4242
* Support for entrypoint scripts and PHP Configuration
43+
* Many common extensions available
4344

4445
## Directories
4546
To facilitate testing and easy setup the following directories are created and owned by www-data by default:
@@ -90,7 +91,74 @@ docker run \
9091
moodle-php-apache:latest
9192
```
9293

94+
## Extensions
95+
96+
The following extensions are inluded as standard:
97+
98+
* apcu
99+
* exif
100+
* gd
101+
* igbinary
102+
* intl
103+
* ldap
104+
* memcached
105+
* mysqli
106+
* oci8
107+
* opcache
108+
* pcov
109+
* pgsql
110+
* redis
111+
* soap
112+
* solr
113+
* sqlsrv
114+
* timezonedb
115+
* uuid
116+
* xdebug
117+
* xhprof
118+
* xmlrpc-beta
119+
* xsl
120+
* zip
121+
122+
All of the above extensions are enabled by default, except for:
123+
124+
* pcov
125+
* xdebug
126+
* xhprof
127+
128+
### Enabling optional extensions
129+
130+
Several extensions are installed, but not enabled. You can enable them easily.
131+
132+
### xdebug
133+
134+
The `xdebug` extension can be enabled by specifying the following environment variable when starting the container:
135+
136+
```bash
137+
PHP_EXTENSION_xdebug=1
138+
```
139+
140+
### xhprof
141+
142+
The `xdebug` extension can be enabled by specifying the following environment variable when starting the container:
143+
144+
```bash
145+
PHP_EXTENSION_xhprof=1
146+
```
147+
148+
#### pcov
149+
150+
The `pcov` extension is typically not used in the web UI, and is no longer recommended for use in code coverage generation in the CLI.
151+
152+
It is currently included but may be removed at a later date.
153+
154+
It can be enabled by specifying the following environment variable when starting the container:
155+
156+
```bash
157+
PHP_INI-pcov.enabled=1
158+
```
159+
93160
## See also
161+
94162
This container is part of a set of containers for Moodle development, see also:
95163

96164
* [moodle-docker](https://github.com/moodlehq/moodle-docker) a docker-composer based set of tools to get Moodle development running with zero configuration

root/tmp/setup/php-extensions.sh

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ docker-php-ext-enable apcu igbinary memcached pcov redis solr timezonedb uuid xm
6969

7070
echo 'apc.enable_cli = On' >> /usr/local/etc/php/conf.d/10-docker-php-ext-apcu.ini
7171

72+
# Install, but do not enable, xdebug and xhprof.
73+
pecl install xdebug xhprof
74+
7275
echo "pcov.enabled=0" >> /usr/local/etc/php/conf.d/10-docker-php-ext-pcov.ini
7376
echo "pcov.exclude='~\/(tests|coverage|vendor|node_modules)\/~'" >> /usr/local/etc/php/conf.d/10-docker-php-ext-pcov.ini
7477
echo "pcov.directory=." >> /usr/local/etc/php/conf.d/10-docker-php-ext-pcov.ini

root/usr/local/bin/moodle-docker-php-ini

+11
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@ $name = $value
2626
2727
EOF
2828
fi
29+
30+
if [[ $fullname = PHP_EXTENSION_* ]]; then
31+
extension=`echo $fullname | sed 's/^PHP_EXTENSION_//'`
32+
echo "=> Found extension to enable: '${extension}'"
33+
if [[ -f "/usr/local/etc/php/conf.d/docker-php-ext-${extension}.ini" ]]; then
34+
echo "=> Extension already enabled: '${extension}'"
35+
else
36+
echo "=> Enabling extension '${extension}'"
37+
docker-php-ext-enable ${extension}
38+
fi
39+
fi
2940
done

tests/fixtures/check-ini.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
$allokay = true;
54
$message = [];
65

@@ -47,6 +46,18 @@
4746
$message[] = "Maximum post size not set to 206M: ({$postmaxsize})";
4847
}
4948

49+
$xhprof = extension_loaded('xhprof');
50+
if (!$xhprof) {
51+
$allokay = false;
52+
$message[] = "xhprof extension not loaded (should be enabled)";
53+
}
54+
55+
$xdebug = extension_loaded('xdebug');
56+
if ($xdebug) {
57+
$allokay = false;
58+
$message[] = "xdebug extension loaded (should be disabled)";
59+
}
60+
5061
if (php_sapi_name() === 'cli') {
5162
if ($allokay) {
5263
echo "OK\n";

0 commit comments

Comments
 (0)