Composer (PHP)

From Biowikifarm Metawiki
Revision as of 18:33, 25 March 2015 by Andreas Plank (Talk | contribs) (Created page with "Some extensions of MediWiki are managed by composer. Documentation: * [https://www.mediawiki.org/wiki/Composer Composer (MediaWiki)] * [http://www.mediawiki.org/wiki/Category:...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Some extensions of MediWiki are managed by composer. Documentation:


Step 0: First install of PHP composer tool itself:

cd ~ # go to personal home directory
sudo curl -sS https://getcomposer.org/installer | php
sudo chown root:mwadmin composer.phar
sudo mv composer.phar /usr/local/bin/


Step 1: Manage your required extensions in file composer.json in the root wiki folder. A basic setup is shipped usually by the Mediawiki installation. File composer.json can look like:

{
  "require": {
    "php": ">=5.3.2",
    "mediawiki/graph-viz": "*",
    "mediawiki/image-map": "@dev",
    "mediawiki/semantic-media-wiki": "~2.0",
    "mediawiki/semantic-result-formats": "2.0",
    "mediawiki/semantic-forms": "3.1",
    "mediawiki/semantic-maps": "3.1.3"
  },
  "suggest": {
    "ext-fileinfo": "More accurate file type detection for uploaded files",
    "ext-mbstring": "Faster unicode handling",
    "ext-wikidiff2": "Faster diff generation",
    "ext-apc": "Speed up MediaWiki with opcode caching (before PHP 5.5)"
  },
  "autoload": {
    "psr-0": {
      "ComposerHookHandler": "includes/composer"
    }
  },
  "scripts": {
    "pre-update-cmd": "ComposerHookHandler::onPreUpdate",
    "pre-install-cmd": "ComposerHookHandler::onPreInstall"
  },
  "config": {
    "optimize-autoloader": true
  }
}

Add an extension

Read the documentation of the extension what kind of version you need, the extension’s documentation should describe it.

The following “require”-command will update your composer.json as well as install the extension including dependencies:

cd /var/www/path/to-wiki-root/
sudo -u www-data php /usr/local/bin/composer.phar require mediawiki/semantic-maps '3.1.3'