Composer

Composer is a dependency manager for PHP libraries. Starting with , MediaWiki core's external library dependencies are being managed with Composer. In addition, it can be used to manage the installation of MediaWiki extensions (available since ). However this is currently not well supported. This may change in the future.

On Unix/Linux and macOS
There are multiple ways to [https://getcomposer.org/download install Composer], besides the most obvious way,  .

Currently, only Composer 1.x is supported by MediaWiki. To grab the latest 1.x stable release:

For users on OS X, you can use [http://brew.sh/ Homebrew] to install Composer. Note this will install version Composer 2.x, so you may want to follow the   instructions above instead. To install using  :

If that doesn't work, or you do not have Homebrew installed, you can try:

Toolforge and the extension distributor use the copy of Composer contained in the "integration/composer" git repo.

Once Composer is installed, you can run commands via the downloaded phar:

You may want to move the phar into your path so it can be used as a normal executable:

If the mv command fails due to permissions, execute it again with sudo.

On Windows
Just download and run the installer from the [<tvar|url>https://getcomposer.org/download</> download page]. If you prefer manual installation, you can follow the above steps except that Windows doesn’t have wget (or APT or Homebrew) by default, and there is no <tvar|1>/usr/local/bin</> directory. In these cases, you can just download [<tvar|url>https://getcomposer.org/composer-1.phar</> composer-1.phar] in your web browser and then rename it to composer.phar.

Upgrading Composer
If you want to upgrade Composer to the latest 1.x stable (or downgrade from 2.x stable), you can use:

If the update command fails due to permissions, execute it again with sudo.

If you are on a really old version of composer, it may not have the <tvar|1> </> parameter. In this case, you might want to run <tvar|2> </> twice. The first may update it to 2.x, so the second will downgrade it to the latest version of 1.x.

Usage in MediaWiki core
MediaWiki 1.25+ depends on some external libraries which are managed with Composer. Composer creates an autoloader at <tvar|1> </>, which is included by <tvar|2> </>.

Composer managed dependencies are bundled into tarball distributions of MediaWiki and extensions so system administrators do not need to use Composer directly. When download>Special:MyLanguage/Download from Git</>|installing MediaWiki using Git, dependencies declared in <tvar|json> </> can either be installed locally by running <tvar|update> </> or the <tvar|vendor> </> repository can be cloned to provide the same libraries used on the Wikimedia production cluster.

Using composer-merge-plugin
MediaWiki core "owns" <tvar|json> </> and will change the contents of that file in both tarball and Git managed updates. In order to allow local installs to use Composer to load optional libraries and/or ext>Special:MyLanguage/Composer/For extensions</>|manage extensions with Composer, a special plugin for Composer named [<tvar|url>https://github.com/wikimedia/composer-merge-plugin</> composer-merge-plugin] was developed. This plugin and the MediaWiki core <tvar|json> </> configuration allow a local deployment to add required extensions and libraries to a file <tvar|local> </> inside the root MediaWiki directory.

<tvar|local> </> can also be used to install Composer managed libraries that are needed by extensions that are not installed using Composer themselves. This is only needed when the extensions are not installed from tarballs generated by special>Special:ExtensionDistributor</>|Extension Distributor.

To enable Composer to discover and process the <tvar|json> </> files that may be included in any and all of your locally installed extensions, add something like this to <tvar|local> </>:

After any changes to <tvar|1> </>, you need to remove <tvar|2> </> before running <tvar|3> </> again so that Composer will recalculate the dependencies and the changes will take effect.

Resources

 * List of extensions that can or must be installed with Composer
 * Composer (software)
 * Composer (software)
 * Composer (software)
 * Composer (software)
 * Composer (software)
 * Composer (software)