Composer/Future work

This page contains some ideas on improving Composer support in MediaWiki.

Preparing MediaWiki
Reuse your MediaWiki installation, in the root directory fill in a composer.json file:

The "require" statement will instruct composer that you want to install the TranslationNotifications extensions. It will take care of resolving the Translate dependency.

Validate your composer.json file:

$ composer validate ./composer.json is valid

resolve dependencies
In your MediaWiki directory, run the composer installer, instructing it to honor any unstable dependencies (aka development packages): $ composer install --verbose Loading composer repositories with package information Installing dependencies - Installing composer/installers (dev-master v1.0.1) Cloning v1.0.1 Cloning into '/srv/trunk/vendor/composer/installers'...

- Installing mediawiki/translate (dev-master 3fadb6b) Cloning 3fadb6bf19fe86226e4e6d35fddd5ebe597be035 Cloning into 'extensions/Translate'... /srv/trunk/extensions/Translate

- Installing mediawiki/translation-notifications (dev-master 440c597) Cloning 440c597a8b01ff2137850b1ef0d28b8ffa365fd9 Cloning into 'extensions/TranslationNotifications'... /srv/trunk/extensions/TranslationNotifications

Writing lock file Generating autoload files $

Extensions have been installed:

$ ls -l ./extensions/ Translate TranslationNotifications $

To have extensions installed in the proper directory, we have crafted https://github.com/composer/installers/pull/37 which makes Composer support MediaWiki extensions (and have them installed in extensions directory).

Our own repository
Create a json representing your repository:

Install satis and create a repo:

create-project composer/satis --stability=dev php bin/satis build  

Scanning packages Reading composer.json of mediawiki/translate (2012.11) Skipped tag 2012.11, no composer file Reading composer.json of mediawiki/translate (2012.12) Skipped tag 2012.12, no composer file Reading composer.json of mediawiki/translate Skipped tag, invalid tag name Reading composer.json of mediawiki/translate (REL1_19) Skipped branch REL1_19, no composer file Reading composer.json of mediawiki/translate (REL1_20) Skipped branch REL1_20, no composer file Reading composer.json of mediawiki/translate (composer) Skipped branch composer, no composer file Reading composer.json of mediawiki/translate (master) Importing branch master (dev-master) Reading composer.json of mediawiki/translate (translatesvg) Skipped branch translatesvg, no composer file Reading composer.json of mediawiki/translate (wmf/1.20wmf10) Skipped branch wmf/1.20wmf10, no composer file Reading composer.json of mediawiki/translate (wmf/1.20wmf8) Skipped branch wmf/1.20wmf8, no composer file Reading composer.json of mediawiki/translate (wmf/1.21wmf1) Skipped branch wmf/1.21wmf1, no composer file Reading composer.json of mediawiki/translate (wmf/1.21wmf7) Skipped branch wmf/1.21wmf7, no composer file Selected mediawiki/translate (dev-master) Reading composer.json of mediawiki/translation-notifications (REL1_20) Skipped branch REL1_20, no composer file Reading composer.json of mediawiki/translation-notifications (composer) Skipped branch composer, no composer file Reading composer.json of mediawiki/translation-notifications (master) Importing branch master (dev-master) Selected mediawiki/translation-notifications (dev-master) Writing packages.json Writing web view

Result is under 

$ ls  total 16 -rw-rw-r-- 1 root root 9836 Jan 29 14:50 index.html -rw-rw-r-- 1 root root 2094 Jan 29 14:50 packages.json $

The index.html is for human consumption. Composer itself will fetch the packagages.json file. Browsing the site gives out: