Manual:Extensions

Extensions are compilations of PHP code that add new features or enhance functionality of the main MediaWiki core. Extensions are one of the main advantages of MediaWiki, by allowing end users to adapt MediaWiki to their requirements.

Installing an extension
MediaWiki is ready to accept extensions just after installation is finished. The steps to take to add an extension are the following:


 * 1) Before you start
 * Some extensions require the installation of a patch. Many of them also provide instructions designed for installation using unix commands. You require shell access (SSH) to enter these commands listed on the extension help pages.
 * 1) Download and install .
 * ExtensionFunctions includes a series of functions that allow extensions to be modularized away from the MediaWiki core code. The best way to install this file is to download the current version from SVN. This file is visible to the public here at all times. Once downloaded, copy the  file to the   subdirectory of your MediaWiki installation.
 * 1) Download your extension.
 * Extensions are usually distributed as modular packages. A list of extensions documented on MediaWiki.org is available on the extension matrix, and a list of extensions stored in the Wikimedia SVN repository is located at svn:trunk/extensions.
 * 1) Install your extension.
 * Generally, at the end of the  file, (but above the PHP end-of-code delimiter, " "), the following line should be added:
 * This line forces the PHP interpreter to read the extension file, and thereby make it accessible to MediaWiki.
 * While this installation procedure is sufficient for many extensions, others require a different installation procedure. Check your extension's documentation for details.
 * While extension declaration can be placed in other places within the LocalSettings.php file, never place extensions before the  line. Doing so will blank the extension setup function arrays, causing no extensions to be installed, and probably will make your wiki inaccessible until you fix it!
 * While extension declaration can be placed in other places within the LocalSettings.php file, never place extensions before the  line. Doing so will blank the extension setup function arrays, causing no extensions to be installed, and probably will make your wiki inaccessible until you fix it!

Writing Extensions
Mediawiki supports several types of extensions. The most common ones are:
 * Extensions that provide additional constructs for use in wiki text - see Extending wiki markup
 * Extensions that provide a new special page - see Writing a new special page
 * Extensions that influence the inner working of Mediawiki - see Manual:MediaWiki hooks
 * Custom skins that change the look & feel of MediaWiki - see Manual:Skinning

Conventions
While an extension can be a single file, it is recommended that for each extension a separate subdirectory  of the extensions directory is created with three files:
 * a small setup file,
 * an internationalisation file,
 * a  file with the bulk of the code.

The setup file adds an element to the  array, which specifies which files are to be loaded:

Extension categorization
Special:Version, defined in SpecialVersion.php, categorizes extensions as follows (and lists them in this order):


 * Special pages
 * Parser hooks - the name in the list is one that is separately specified in the extension, in the array $wgExtensionCredits, so not necessarily exactly the name of a tag, parser function, or PHP function.
 * Variables
 * Other
 * Extension functions - These are the setup functions called before any specific action takes place (such as parsing a page for viewing), to define various functions in preparation of using them. For example, it connects parser function IDs to PHP functions.
 * Parser extension tags - XML-style tags  some text
 * Parser function hooks -
 * Skin extension functions

There is a separate Hooks section in Special:Version. The first column shows the hook name, e.g., and the second column lists the functions which subscribe to this hook; in the case of hook   the function name is usually of the form " ". These functions define for each language and each extension function ID all magic words that can be used in the wikitext to refer to the function.

Some extensions call  without adding anything to array. They are not listed here.