Installation with shell access using Composer (MediaWiki 1.25+)

From semantic-mediawiki.org
< Installation
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[edit]

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[edit]

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[edit]

Make sure that you have a compatible version of MediaWiki installed. 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[edit]

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

If you do not have a "composer.local.json" file yet, create one and add the following content to it:

{
	"require": {
                  "mediawiki/semantic-media-wiki": "~3.0"
        }
}

If you already have a "composer.local.json" file add the following line to the end of the "require" section in your file:

"mediawiki/semantic-media-wiki": "~3.1"

Remember to add a comma to the end of the preceding line in this section. See an example "composer.local.json" file.

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 4.1.2" you will have to replace "~3.1" with "~4.2" (latest stable release) etc. Please always omit the bugfix release number, i.e. the third digit. Additional information about the ~ usage can be found here.

Run the update script[edit]

Run the installation script from the base directory2 of your MediaWiki installation:

php composer.phar update --no-dev

Note if you have Git installed on your system add the --prefer-source flag to the above command. Also note that it may be necessary to run this command twice. If unsure do it twice right away.

Run the maintenance script[edit]

Run the setup script from the base directory2 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[edit]

BREAKING: As of Semantic MediaWiki 4.0.0Released on 18 January 2022 and compatible with MW 1.35.0 - 1.37.x. you need to add wfLoadExtension( 'SemanticMediaWiki' ); to LocalSettings.php !

Until SMW 3.2.x only enableSemantics( 'example.org' ); was used to invoke SMW.

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' );

Starting with Semantic MediaWiki 3.1.0Released on 23 September 2019 and compatible with MW 1.31.0 - 1.33.x. an informative error description page will be shown if this was forgotten for some reason.3

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

Add optional settings4 apart from one exception namely configuration parameter $smwgNamespaceIndexSets the index of the first namespace to be used by Semantic MediaWiki5 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 11 October 2018 and compatible with MW 1.27.0 - 1.31.x. MediaWiki's extension registration system is used.6 The loading of the extension is however solely done via the enableSemantics() call.

Check and verify[edit]

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[edit]

Use these instructions to update an existing Semantic MediaWiki installation.

Backup[edit]

Backup your database and installation.

Run the update script[edit]

Run the update script from the base directory2 of your MediaWiki installation:7

php composer.phar update --no-dev

Note if you have Git installed on your system add the --prefer-source flag to the above command. Also note that it may be necessary to run this command twice. If unsure do it twice right away.

Run the maintenance script[edit]

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

php maintenance/update.php

Run the refresh database script from the base directory2 of your MediaWiki installation:8

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

Check and verify[edit]

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

Done!

Upgrade[edit]

See also[edit]






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. a b c d e  This is the directory which contains the "LocalSettings.php" file.
  3. ^  Semantic MediaWiki: GitHub pull request gh:smw:4153
  4. ^  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.
  5. ^  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.
  6. ^  Semantic MediaWiki: GitHub pull request gh:smw:1732
  7. ^  In case you installed Composer "globally" on your server, you will have to drop the php and .phar particles from the command.
  8. ^  rebuildData.php is an optional step to take to assure that the semantic store is valid and up to date