Composer/For extension developers

Developer resources
A more up to date list of instructions can be found in Introduction to Composer for MediaWiki developers.

On packagist.org
Packagist.org is the central composer package repository.

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 only accessible to Wikimedia Foundation Operations team (they used to be on fenari:/home/wikipedia/doc/packagist.org but got moved RT #6665). Legoktm has access to the account, so poke him if you want a package added.


 * MediaWiki core
 * Packages tagged with "MediaWiki"

composer.json
You want to add a composer.json file in your extension. Here is an example from Translate:

More examples can be found at Manual:composer.json best practices.

Then we check the syntax to avoid mistakes: $ composer validate ./composer.json is valid

Test composer.json
Before you commit your, you should test it. There is a chicken-and-egg problem here. You must commit your extension's  before you publish the extension in packagist. To solve this problem, you can use your local repository instead of packagist.

Add or edit the  file in your main MediaWiki directory (your test environment) to add your local repository to composers list of repositories to look for packages.

The following example assumes you are using Git as your VCS. Because composers repository type  works with bare git repositories only (and not working trees) you must let the  -attribute point directly to your  instead of your working tree (this is the  -subdirectory inside your repository in most cases). Now add the following lines to the  file:

Now you can test your extension's installation by specifying an according -attribute inside your   file. Composer will match an according tag or branch name from your local repository then.

Publish extension in packagist
See Manual:Developing libraries for information on how to add your extension to packagist.org.

Choose a maintenance model

 * Release branch: You should provide patches to certain release branches (e.g. LTS and last stable) and make sure the extension works properly with the corresponding version of MediaWiki Core
 * Semantic versioning: Add tags according to SemVer. Make sure that compatibility to MediaWiki Core is only changed in major releases

Be packagist.org compatible
In your  make sure you feature all fields that are required by a package repository like packagist.org.

Example:

Set proper keywords

 * "mediawiki"