Composer

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

Composer (コンポーザー) は、PHP のライブラリの依存関係マネージャーです。 MediaWiki 1.25 以降、MediaWiki コアの外部ライブラリの依存関係は Composer で管理されています。 さらに、MediaWiki 拡張機能のインストールの管理にも使用できます (MediaWiki 1.22 以降で利用できます)。 However this is currently not well supported. This may change in the future.

Composer のインストール

Unix/Linux、macOS 上

install Composer には、最も明白な方法である sudo apt install composer に加えて、複数の方法があります。

Only Composer 1.x is supported by MediaWiki 1.31, 1.35.0 and 1.35.1. 最新の 1.x 安定版リリースを取得するには以下を実行します:

wget -cO - https://getcomposer.org/composer-1.phar > composer.phar

Composer 2.x and Composer 1.x are supported by MediaWiki >= 1.35.2 (along with the REL1_36 branch and master). To grab the latest Composer 2.x stable release:

wget -cO - https://getcomposer.org/composer-2.phar > composer.phar

OS X を使用している場合は、Composer のインストールに Homebrew を使用できます。 Note this will install version Composer 2.x, so depending on the version of MediaWiki you are using, you may need to follow the wget instructions above instead to download Composer 1.x. To install using brew:

brew install composer

動作しない場合、または Homebrew がインストールされていない場合は、以下をお試しください:

php -r "readfile('https://getcomposer.org/installer');" | php

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

Composer をインストールすると、ダウンロードした phar 経由で以下のようにコマンドを実行できるようになります:

php composer.phar someCommand

phar をパスが通っている場所に移動すると、通常の実行可能ファイルと同様に使用できます:

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

mv コマンドが権限が原因で失敗した場合は、sudo を付けてもう一度お試しください。

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

Windows 上

Just download and run the installer from the 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 /usr/local/bin directory. In these cases, you can just download composer-1.phar in your web browser and then rename it to composer.phar.

Composer のアップグレード

Composer 1.x

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

composer self-update --1

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

sudo composer self-update --1

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

composer self-update
composer self-update --1

Composer 2.x

If you are using Composer 1.x, and want to upgrade to Composer 2.x (and are using an appropriate version of MediaWiki, such as >= 1.35.2), you can use:

composer self-update --2

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

sudo composer self-update --2

MediaWiki コアでの使用法

MediaWiki 1.25 以降は、Composer で管理されているいくつかの外部ライブラリに依存しています。 Composer は、WebStart.php によってインクルードされる自動ローダーを vendor/autoload.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 は、あなたが MediaWiki をインストールしたインストールパス (または「ディレクトリ」) を意味します (Install Path の略)。そのディレクトリには LocalSettings.php index.php などがあります。

composer-merge-plugin の使用

$IP は、あなたが MediaWiki をインストールしたインストールパス (または「ディレクトリ」) を意味します (Install Path の略)。そのディレクトリには LocalSettings.php index.php などがあります。

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": [
                "extensions/*/composer.json",
                "skins/*/composer.json"
            ]
        }
    }
}

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.

リソース

脚注