Installation with shell access using Composer (MediaWiki 1.25+)

From semantic-mediawiki.org
Administrator manualInstallationInstallation with shell access using Composer (MediaWiki 1.25+)
Installation
This pages describes the installation using native Composer support
Image / Video collection
Further Information
Installation type: new
Installation method: Composer
MediaWiki version: 1.25.0 and later
Table of Contents

Fresh install

Use these instructions for a new Semantic MediaWiki installation in chronological order as they appear on this page.

Please also consult our page on troubleshooting in case you encounter issues during the process.

Install Composer

Install Composer first since this software is required to install Semantic MediaWiki. Please follow the instructions at installing Composer on how to do this.

Check compatibility

Special page "Version" contains the MediaWiki version and it is recommended to compare compatibility with Update to the appropriate version of MediaWiki and COMPATIBILITY.md.

Using Composer

MediaWiki 1.25+ itself started to facilitate the use of the "composer.json" file for its own library dependency management. Therefore it is strongly encouraged to use the "composer.local.json" file to add local packages to avoid merge conflicts with subsequent software updates instead of issuing the commands shown below.1 Since "composer.local.json" is a MediaWiki specific convention, composer require does not work on this file and instead has to be edited manually. See an example "composer.local.json" file for how to proceed.

Run the following "initialization" command23 from the base directory4 of your MediaWiki installation:5

php composer.phar require mediawiki/semantic-media-wiki "~2.5" --update-no-dev

or alternatively if Composer is installed globally

composer require mediawiki/semantic-media-wiki "~2.5" --update-no-dev
The version stated in the line above is provided as an example. See the Releases page on GitHub for newer releases. If there is e.g. a release called "SMW 2.2.0" you will have to replace "~2.5" with "~2.5" (latest stable release) etc. Please always omit the bugfix release number, i.e. the third number with additional information about the ~ usage can be found here.

Run the maintenance script

Run the setup script from the base directory4 of your MediaWiki installation:
php maintenance/update.php
Add --skip-external-dependencies to the call of the setup script if you get an error message similar to the following one:
mediawiki/semantic-media-wiki: 2.5.0 installed, ~2.5 required.

Enable Semantic MediaWiki

Add a call to enableSemantics() to the end of the "LocalSettings.php" file. enableSemantics() takes in the domain name of the wiki; a wiki located at "example.org", for instance, should have the following call:

enableSemantics( 'example.org' );
The calls require_once ( … );, wfLoadExtension( … ); or wfLoadExtensions( … );must not be added to invoke Semantic MediaWiki.

Add optional settings6 apart from one exception namely configuration parameter $smwgNamespaceIndexSets the index of the first namespace to be used by Semantic MediaWiki7 to the "LocalSettings.php" file as desired below the enableSemantics() call.

In case you want to use additional semantic extensions please refer to their respective documentation on how to invoke them. In any case make sure that you invoke them below the enableSemantics() call in your "LocalSettings.php" file.

Since Semantic MediaWiki 3.0.0Released on an unknown date and compatible with MW 1.27.0 - 1.30.x. MediaWiki's extension registration system is used.8 The loading of the extension is however solely done via the enableSemantics() call.

Check and verify

Check the "Special:Version" page on your wiki and verify that the extension has been successfully installed and enabled.

Test your installation as described on the help page about testing Semantic MediaWiki.

Done!

Update

Use these instructions to update an existing Semantic MediaWiki installation.

Backup

Backup your database and installation.

Run Composer update

Run the update script from the base directory4 of your MediaWiki installation:5

php composer.phar update --no-dev

or alternatively if Composer is installed globally

composer update --no-dev

Run maintenance script

Run the setup script from the base directory4 of your MediaWiki installation:

php maintenance/update.php

Run the refresh database script from the base directory4 of your MediaWiki installation:9

php extensions/SemanticMediaWiki/maintenance/rebuildData.php -d 50 -v

Check and verify

Check the "Special:Version" page on your wiki and verify that the extension has been successfully updated.

Done!

Upgrade

See the help page on upgrading from SMW 1.9+ for MW 1.22+

See also





References

  1. ^  Using composer-merge-plugin to "... allow local installs to use Composer to load optional libraries and/or manage extensions with Composer ... local deployment to add required extensions and libraries to a file composer.local.json inside the root MediaWiki directory"
  2. ^  This is necessary since starting with MW 1.25+ MediaWiki MediaWiki itself uses Composer to facilitate components and packages.
  3. ^  Note that, if you have Git installed, it's recommended to install composer with the "--prefer-source" flag, so that Composer uses Git to download the code. In other words, instead of calling "composer update" or "php composer.phar update", as that page states, you should call "composer update --prefer-source" or "php composer.phar update --prefer-source".
  4. a b c d e  This is the directory which contains the "LocalSettings.php" file.
  5. a b  In case you installed Composer "globally" on your server, you will have to drop the php and .phar particles from the command.
  6. ^  See the help page on configuring SMW. Usually only a few configuration parameters have to be changed if there is a need to do so at all.
  7. ^  If you manually set $smwgNamespaceIndex to something other than the default value of 100, you must do this above the enableSemantics() line instead. Make sure that the value set is ≥ 100 as well as an even number.
  8. ^  Semantic MediaWiki: GitHub pull request gh:smw:1732
  9. ^  rebuildData.php is an optional step to take to assure that the semantic store is valid and up to date