MediaWiki-Docker/Configuration recipes/Develop PHP extension

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

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

If you use a MediaWiki-Docker container with a PHP version different from production, then the container will have https://deb.sury.org/ pre-configured and makes packages available suitable to your PHP version, e.g..

Compile
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  is installed.
 * Follow regular steps using  as per individual README.

you:mediawiki$ mkdir tmp/ && cd tmp/ you:mediawiki/tmp$ git clone ssh://gerrit.wikimedia.org:29418/mediawiki/php/excimer 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 root@container:mediawiki/tmp/excimer$ php -d 'extension=excimer.so' -i | fgrep excimer excimer support => enabled excimer version => x.x.x $ echo 'extension=wikidiff2.so' > /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
 * 1) Confirm:
 * 1) Enable for Apache and php-cli