Jump to navigation Jump to search
This page is a translated version of the page Composer and the translation is 41% complete.
Outdated translations are marked like this.
Other languages:
English • ‎Türkçe • ‎español • ‎français • ‎magyar • ‎português • ‎русский • ‎中文 • ‎日本語

Composer é um gestor de dependências para as bibliotecas de PHP. Além disso, este pode ser utilizado para gerir a instalação das extensões do MediaWiki (disponível desde MediaWiki 1.22 ). A partir de MediaWiki 1.25 , as dependências de biblioteca externas do núcleo do MediaWiki estão a ser geridas com o Composer.

Instalação do Composer

No Unix/Linux e macOS

Existem várias maneiras para o install Composer, além da maneira mais óbvia, sudo apt install composer:

Para obter um instantâneo mais recente:

wget -cO - > composer.phar

Isso transfere um instantâneo do máster atual e expirará em 30 dias.

There are also phars for the alpha "releases" such as 1.0.0-alpha.

For users on OS X, you can use Homebrew to install composer:

brew install composer

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

php -r "readfile('');" | php

Jenkins 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:

php composer.phar someCommand

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

mv composer.phar /usr/local/bin/composer
composer someCommand

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

No Windows

Basta transferir e executar o instalador da página de transferências. 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 /usr/local/bin directory.

Utilização no núcleo do MediaWiki

MediaWiki 1.25+ depends on some external libraries which are managed with Composer. Composer creates an autoloader at vendor/autoload.php, which is included by WebStart.php.

Composer managed dependencies are bundled into tarball distributions of MediaWiki and extensions so system administrators do not need to use composer directly. When installing MediaWiki using Git, dependencies declared in $IP/composer.json can either be installed locally by running composer update --no-dev or the mediawiki/vendor.git repository can be cloned to provide the same libraries used on the Wikimedia production cluster.[1]

$IP stands for the Installation Path (or "directory") of your MediaWiki installation, the same directory that holds LocalSettings.php , index.php etc..

Utilizar o plug-in de unir do "composer"

$IP stands for the Installation Path (or "directory") of your MediaWiki installation, the same directory that holds LocalSettings.php , index.php etc..

MediaWiki core "owns" $IP/composer.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 manage extensions with Composer, a special plugin for Composer named composer-merge-plugin was developed.[2] This plugin and the MediaWiki core composer.json configuration allow a local deployment to add required extensions and libraries to a file composer.local.json inside the root MediaWiki directory.

composer.local.json 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 Extension Distributor.

To enable Composer to discover and process the composer.json files that may be included in any and all of your locally installed extensions, add something like this to $IP/composer.local.json:

    "extra": {
        "merge-plugin": {
            "include": [

After any changes to composer.local.json, you need to remove composer.lock before running composer install again so that Composer will recalculate the dependencies and the changes will take effect.