Composer

As of MediaWiki 1.22, one can install extensions using Composer.

What is composer
Composer is a dependency manager that automates many of the tasks one has to deal with when installing extensions. The following points do no longer have to be dealt with if you install extensions with Composer:


 * 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)

Current status
Extension installation in MediaWiki is only possible since version 1.22. If you have an older version of MediaWiki, you can use the Extension Installer extension to achieve the same capabilities.

In order for an extension to be installable with Composer, it needs to provide certain details. As a result, most MediaWiki extensions are not currently installable with Composer. You can look at the list of packages tagged with "MediaWiki" on Packagist to find the extensions that can already be installed via Composer.

Installing Composer
Download Composer. See the instructions on that download page for all options. Important to note is that one can simply get the composer.phar file and run composer via this file.

wget http://getcomposer.org/composer.phar php composer.phar someCommand

This is equivalent to doing an actually installation of Composer and the running

composer someCommand

Specify the extensions to be installed
Copy the composer-example.json file to a new file named composer.json.

In this file, add the extensions you want to install in the "require" section. See "declaring dependencies" and "package setup". Or have a look at the examples below.

The default contents of the json file specifies nothing should be installed, and looks as follows:

This example specifies that the SubPageList extension should be installed. It also specifies that you want version 1.0 or above.

For each additional extension you need, a new line is added. This example also adds Semantic MediaWiki, and specifies that you are happy with the latest version compatible with your setup.

Each line, except the last one, should have a comma at the end. Also note that you only need to specify the extensions you need, and do not have to bother with their dependencies. For instance, if you want to install Semantic Maps, Composer will automatically install it's dependencies, such as Maps and Semantic MediaWiki, for you.

Installing and updating extensions
Once you specified the extensions you want to install, run " ". To verify installation was successful, hit Special:Version and see if the desired extensions are listed.

When you want a new version of an extension, update the versions in the composer.json file, and run " ".

On packagist.org
A "mediawiki" user exists on Packagist to have GitHub notify packagist whenever a new commit land in the repository. The credentials for the mediawiki user are on fenari:/home/wikipedia/doc/packagist.org


 * MediaWiki core
 * Packages tagged with "MediaWiki"

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.