Hey,
Over the past few months a number of people have been poking at Composer [0] support for MediaWiki [1]. Today I had a look at this and found that though we are close to getting this to work, there are a few remaining problems to be tackled.
1. MediaWiki needs to load the composer autoloader when present.
There currently already is some code in core to do this, though this code is placed at a to early point, resulting in things registered by extensions getting overridden by DefaultSettings.
I made an attemtp to fix this [2] by placing the inclusion of the autoloader after the one of LocalSettings (see patchset 2). As Hashar pointed out, this prevents one from changing the default configuration of extensions. Inclusion of the autoloader thus needs to happen before the end of LocalSettings. It also needs to happen after the start of LocalSettings, since some extensions need the core configuration to be set already or require the user to define things before they get included. This basically means the only place where we can put it is in LocalSettings, on the same place where people typically include extensions. This is what is done in PS3. Does anyone see a better way to do this?
2. Installing extensions leaves the composer.json file modified.
When installing one or more extensions via Composer, they will get added to the require section in composer.json. composer.json is not in the gitignore list. So you might well run into conflicts here, and in any case will have a modified file that is tracked in your git repo, which is annoying. In case of extension installation via LocalSettings, this stuff is in a file that is in gitignore. We could just add composer.json there as well, but this means that when we make changes to it on master, people will not get them any time soon. This is problematic in case we where to make MW core dependent on other packages, though this seems unlikely to happen, and is thus perhaps just a theoretical concern. Does anyone see a way around this problem better than putting composer.json in gitignore? Any concerns with putting it in gitignore?
3. Not clear how to best install an extension
The best command to use for installation of an extension when you already have MediaWiki seems to be "composer require", for instance "composer require ask/ask:dev-master". When using this command, apparently the require-dev packages are also installed. Since MW specifies PHPUnit in require-dev, it is installed, together with all of its dependencies (quite some code) for no good reason. In case of the require command, there appears to be no way to specify it should not get the dev packages.
An alternate approach to installation is to add the things to install manually in the require section of composer.json and do a "composer update --no-dev". This approach might be fine when doing a manual install, though it clearly does not work well when you want to automate it (ie in a CI build process).
Again, does anyone know of a better way to do such an install? And if not, perhaps we can simply get rid of the require-dev section in our composer.json file so we do not run into the problem its causing when using "composer require"?
[0] http://getcomposer.org/ [1] https://www.mediawiki.org/wiki/Composer [2] https://gerrit.wikimedia.org/r/#/c/71616/
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. ~=[,,_,,]:3 --