MediaWiki-Docker/Configuration recipes/Develop PHP extension

Wikimedia maintains a number of native PHP extensions written in C, this includes: Excimer, Wmerrors, LuaSandbox

Quick installEdit

Our packages should be available from apt-get in all supported PHP versions. We generally upstream to Debian stable, which MediaWiki-Docker uses, and the production version will also be packaged in which is pre-configured in MediaWiki containers that use the production PHP version. E.g. apt-get install php-excimer.

If you use a MediaWiki-Docker container with a PHP version different from production, then the container will have pre-configured and makes packages available suitable to your PHP version, e.g. php8.1-excimer.


To test changes to a C extension to PHP in the same environment as MediaWiki, largely:

  • Keep the relevant Git checkout somewhere under mediawiki/ to make it easier to interact with from the container (automatically mounted).
  • Ensure php-dev is installed.
  • Follow regular steps using make as per individual README.
you:mediawiki$ mkdir tmp/ && cd tmp/
you:mediawiki/tmp$ git clone ssh://

you:mediawiki$ docker compose exec -u root mediawiki bash
root@container:mediawiki$ apt-get install php-dev

root@container:mediawiki/tmp/excimer$ phpize
root@container:mediawiki/tmp/excimer$ ./configure
root@container:mediawiki/tmp/excimer$ make
root@container:mediawiki/tmp/excimer$ make install

# Confirm:
root@container:mediawiki/tmp/excimer$ php -d '' -i | fgrep excimer
  excimer support => enabled
  excimer version => x.x.x

# Enable for Apache and php-cli
$ echo '' > /etc/php/8.1/mods-available/wikidiff2.ini
$ ln -s /etc/php/8.1/mods-available/wikidiff2.ini /etc/php/8.1/apache2/conf.d/wikidiff2.ini
$ ln -s /etc/php/8.1/mods-available/wikidiff2.ini /etc/php/8.1/cli/conf.d/wikidiff2.ini
$ ln -s /etc/php/8.1/mods-available/wikidiff2.ini /etc/php/8.1/fpm/conf.d/wikidiff2.ini