Composer/Future work
This page is currently a draft.
|
This page contains some ideas on improving Composer support in MediaWiki.
Preparing MediaWiki
[edit]Reuse your MediaWiki installation, in the root directory fill in a composer.json file:
{
"name": "mediawiki/core",
"description": "My personal MediaWiki installation",
"license" : "GPL-2.0+",
"repositories": [
{
"type": "composer",
"url": "http://integration-composer.instance-proxy.wmflabs.org/"
}
],
"require": {
"mediawiki/translation-notifications": "dev-master"
},
"minimum-stability": "dev"
}
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
[edit]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
[edit]Create a json representing your repository:
{
"name": "Wikimedia Composer repository",
"homepage": "http://integration-composer.instance-proxy.wmflabs.org/",
"repositories": [
{ "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/Translate" },
{ "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/TranslationNotifications" }
],
"require-all": true
}
Install satis and create a repo:
create-project composer/satis --stability=dev php bin/satis build <composer.json> <build-dir>
Scanning packages Reading composer.json of mediawiki/translate (2012.11) <warning>Skipped tag 2012.11, no composer file</warning> Reading composer.json of mediawiki/translate (2012.12) <warning>Skipped tag 2012.12, no composer file</warning> Reading composer.json of mediawiki/translate () <warning>Skipped tag , invalid tag name</warning> Reading composer.json of mediawiki/translate (REL1_19) <warning>Skipped branch REL1_19, no composer file</warning> Reading composer.json of mediawiki/translate (REL1_20) <warning>Skipped branch REL1_20, no composer file</warning> Reading composer.json of mediawiki/translate (composer) <warning>Skipped branch composer, no composer file</warning> Reading composer.json of mediawiki/translate (master) Importing branch master (dev-master) Reading composer.json of mediawiki/translate (translatesvg) <warning>Skipped branch translatesvg, no composer file</warning> Reading composer.json of mediawiki/translate (wmf/1.20wmf10) <warning>Skipped branch wmf/1.20wmf10, no composer file</warning> Reading composer.json of mediawiki/translate (wmf/1.20wmf8) <warning>Skipped branch wmf/1.20wmf8, no composer file</warning> Reading composer.json of mediawiki/translate (wmf/1.21wmf1) <warning>Skipped branch wmf/1.21wmf1, no composer file</warning> Reading composer.json of mediawiki/translate (wmf/1.21wmf7) <warning>Skipped branch wmf/1.21wmf7, no composer file</warning> Selected mediawiki/translate (dev-master) Reading composer.json of mediawiki/translation-notifications (REL1_20) <warning>Skipped branch REL1_20, no composer file</warning> Reading composer.json of mediawiki/translation-notifications (composer) <warning>Skipped branch composer, no composer file</warning> 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 <build-dir>
$ ls <build-dir> 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: