Manual:Composer.json best practices

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 [https://getcomposer.org/doc/03-cli.md#validate composer validate], which will point out schema errors.

Configuration
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 [https://github.com/wmde/WikidataBuilder/pull/32 this] for some more details.
 * "prepend-autoloader": false.


 * "optimize-autoloader": true. No reason not to optimize.

Good example: [https://github.com/wikimedia/mediawiki/blob/master/composer.json mediawiki/core]

Dependencies

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


 * For development tools like phpunit or phpcs, "dev-master" or "*" is acceptable.

Good example: [https://github.com/wikimedia/mediawiki/blob/master/composer.json mediawiki/core]

Extensions
Extensions should be named using -'s and all lowercase. For example:


 * Extension:WikiEditor --> mediawiki/wiki-editor


 * Extension:MassMessage --> mediawiki/mass-message

To make themselves installable, a dependency upon "composer/installers" is needed, and the type needs to be set to "mediawiki-extension".

Good example: [https://github.com/wikimedia/mediawiki-extensions-Bootstrap/blob/master/composer.json 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".

Good example: [https://github.com/wikimedia/mediawiki-skins-Vector/blob/master/composer.json mediawiki/skins/Vector]