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. To add an extension follow these steps:


 * 1) Before you start
 * A few 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 .
 * Some extensions, especially newer ones, require a helper file called .  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. They generally go in their own subdirectory of .  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 most extensions, some 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 Manual:Tag Extensions and Manual:Parser Functions
 * Extensions that provide a new special page - see Manual:Special Pages
 * Extensions that influence the inner working of Mediawiki - see Manual:Hooks
 * Custom authentication mechanisms - see AuthPlugin
 * Custom skins that change the look & feel of MediaWiki - see Manual:Skinning

See also the Extensions FAQ.

Credits
You can cause your extension along with credit information to be shown on the Special:Version page (see also Extension categorization below). To do so, add your extension to the Manual:$wgExtensionCredits array:

validextensionclass must be one of specialpage, parserhook, variable, other, as specified on Manual:$wgExtensionCredits.

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
Extensions fall roughly into the following categories. Many complex extensions include one or more of these types in one package.


 * Special pages - Special pages are the little bits of extra logic that are helpful. MediaWiki 1.5 offers reflective extension loading, which means hooking up your extension to the system is fast and easy. The possibilities for special pages are boundless, only limited by your programming ability.
 * 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.
 * Magic words - Magic words are variables that cause something to occur on a wiki page. There are a number of predefined magic words and extensions can define others.  See also the  LanguageGetMagic hook.
 * Extension tags - XML style tags. The parser is very flexible, and you can give it custom hooks for specific XML tags. For instance, if you wanted to make a form that let users subscribe to a server mailing list, instead of enabling HTML, you could write an extension that parses  into a form.  Tag extensions return HTML.
 * Parser functions - . Similar to tag extensions, parser functions process arguments and returns a value.  Unlike tag extensions, the result of parser functions is wikitext.
 * Skins - Skins change the look and feel of MediaWiki by altering the code that outputs pages.