During SMWCon earlier this week I hacked up a tool to install MediaWiki extensions with Composer.
Composer is a dependency manager, in other words a tool that automates many of the tasks that people installing MediaWiki extensions currently need to deal with manually.
Right now one needs to bother with all of these things when installing a MediaWiki extension:
- Where do I download it from, and how? (A: this depends on the extension and can vary a lot)
- Where do I put it, and how do I load it? (A: editing a PHP file and adding a PHP includes into it)
- What other extensions or libraries are needed? (A: it depends, and often this is not well documented)
- What versions of those extensions are compatible? (A: it depends, and rarely is well documented)
- In what order do I need to include the extensions? (A: indeed, it depends, and is often not well documented)
And this process need to be applies recursively to all dependencies. Ugh! Not exactly user friendly.
And this whole list ought to simply not be there, as this work can be automated. This is what Composer does.
So why does MediaWiki not support this? There are a few hurdles:
1. Each extension needs to specify its dependencies in a structured format. This is similar is with other types of packages, such as debian packages or npm packages. While this is not hard to do, extension authors do need to first provided this before their extensions can be installed with Composer.
2. A lot of extensions follow the bad practice of assuming they get included in global scope. This is a technical issue, which comes again down to most extensions needing some work before they can be installed with Composer.
3. Due to political issues in the core MediaWiki community, it is hard to get proper support for Composer in MediaWiki itself.
A lot of my extensions support installation via Composer right now. The only thing that prevented people from using this support was the third point, lacking support in MediaWiki core.
Not so long ago I realized that it’d be trivial to create a small wrapper around Composer that pretends to be a MediaWiki extension, and is installed as MediaWiki extension. And then once installed, people can install other extensions on top of it.
This is exactly what I ended up doing. You can download it from GitHub, where the documentation is also located.
- Documentation: https://github.com/JeroenDeDauw/ExtensionInstaller
- Download as zip
- Git clone: https://github.com/JeroenDeDauw/ExtensionInstaller.git
The documentation there explains how to install and use this extension installer, as well as how to find existing extensions that support installation via it.
Going on the very positive reception at SMWCon, I hope that this will make users lives easier.
Things I’d like to see happen to further improve extension installation are:
- Have MediaWiki core support extension installation via Composer, so this meta-extension is not needed.
- Have a user interface build on top of Composer, so people are not forced to use the command line if they don’t want to do so.