Manual:Composer.json best practices/de

This page is a translated version of the page Manual:Composer.json best practices and the translation is 24% complete.
Outdated translations are marked like this.

When creating a composer.json file for your extension/library/etc that will be used inside MediaWiki, here are a few best practices to follow. You should also run composer validate, which will point out schema errors.

  • prepend-autoloader: false. Composer's autoloader is slower than MediaWiki's, and most of the classes being loaded are likely to be found inside MediaWiki, so append the Composer autoloader instead of prepending it. See this for some more details.
  • optimize-autoloader: true. No reason not to optimize.

Gutes Beispiel: mediawiki/core

Abhängigkeiten

Dependencies should be pinned to a specific version number or sha1 commit if a tag isn't available.

Gutes Beispiel: mediawiki/core

Benennung

Libraries hosted in Gerrit or by the Wikimedia GitHub account should typically be published under the "wikimedia" namespace (e.g. "wikimedia/cdb", "wikimedia/simplei18n"). The use of the "mediawiki" namespace should be reserved for extensions and other intrinsically MediaWiki related components (bot frameworks, etc). Projects hosted at GitHub under an independent organization are encouraged to adopt a similar convention of an organization namespace to be applied consistently across the libraries published by the group.

Autoren

Major authors to the project should be documented in the "authors" property. At least the name and email fields should be filled out.

Extensions and skins

Erweiterungen

Extension names should be all lowercase with hyphens as word separators. For example:

  • Erweiterung:WikiEditor --> mediawiki/wiki-editor
  • Erweiterung:MassMessage --> mediawiki/mass-message

To make themselves installable, a dependency upon "composer/installers" with version >= 1.0.1 is required (a reasonable value for this field is "^2|^1.0.1"), and the type needs to be set to "mediawiki-extension".

Gutes Beispiel: mediawiki/extensions/Bootstrap

Skins

Mainly the same as extensions, except the type should be "mediawiki-skin". The names should end with a suffix of "-skin".

Because Composer uses lowercase names for packages (e.g. mediawiki/vector-skin), the extra.installer-name property must be set to the uppercase name (e.g. Vector) so it is cloned in the right directory.

Gutes Beispiel: mediawiki/skins/Vector

Overlaps with extension.json and skin.json

Extensions and skins register information about themselves using an extension.json or skin.json file. Some metadata fields in these files overlap, including:

  • homepage vs. url
  • license vs. license-name

The redundancy of data between extension/skin.json and composer.json has been discussed (see task T89456), but current consensus is that it is unavoidable.