Composer

For a long time we had an issue resolving extensions dependencies. The composer/packagist system might be of some help. This article explain you how to set up extension to take advantage of that dependency manager.

Composer is available at http://getcomposer.org/, it is a package manager for PHP. The biggest repository is http://packagist.org/ which let you upload your packages by simply pasting a git URL. All you need is to drop in a composer.json file at the root of your extension directory. My example will be with setting up a MediaWiki installation and install the Translate and TranslationNotification extensions.

install composer
On Mac OS X with homebrew, it is as easy as `brew install composer`. Other users can have a look at the Composer installation page.

composer.json
At first we create the composer.json files in the Translate extension:

Similarly for the TranslationNotification extension:

Publish extension in packagist
Then send that in the git repository of your choice. Antoine "hashar" Musso used his GitHub project to hold them:
 * https://github.com/hashar/mwext-Translate.git
 * https://github.com/hashar/mwext-TranslationNotifications.git

We then go to the http://packagist.org/ repository and submit the package. You will need to create an account then fill in the GIT repository URL. The packagist website will fetch the composer.json from your repository and happily add the package to the repository.

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. The "vendor-dir" is where extensions are going to be download.

resolve dependencies
In your MediaWiki directory, run the composer installer, instructing it to honor any unstable dependencies (aka development packages):

$ composer install --dev Installing dependencies - Installing mediawiki/translate (dev-master d4f45a) Cloning d4f45a37e5c4b28efca0cee8098e941b8ca5837c - Installing mediawiki/translation-notifications (dev-master f5c09a) Cloning f5c09aecf0b2be50c742a2c59c5b49073af8348f Installing dev dependencies Nothing to install or update Writing lock file Generating autoload files $

Extensions have been installed:

$ ls -l extensions/mediawiki/ translate translation-notifications $

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