Extensions add functionality to MediaWiki without modifying core files. They integrate with MediaWiki through a standardized registration system based onDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/wikimedia/mediawiki/llms.txt
Use this file to discover all available pages before exploring further.
extension.json and a set of well-defined extension points including hooks, services, special pages, resource modules, and more.
Loading an Extension
Extensions are loaded inLocalSettings.php using wfLoadExtension():
extensions/FoodProcessor/extension.json and register everything the extension declares.
extension.json Structure
Every extension must have anextension.json file at its root. The file conforms to the MediaWiki extension schema (v2).
Required Fields
manifest_version and name are required. All other fields are optional.
Identification Fields
type field categorizes the extension. Common values include api, antispam, editor, media, parserhook, semantic, specialpage, and other.
Version Constraints with requires
Use the requires field to declare minimum versions of MediaWiki, PHP, or other extensions:
>=, <, ~, etc.). The requires.MediaWiki field is checked at load time and will prevent the extension from loading if the constraint is not satisfied.
AutoloadNamespaces (PSR-4)
Map PHP namespaces to directories for autoloading:AutoloadNamespaces is for PSR-4 autoloading. The older AutoloadClasses field maps individual class names to file paths and is still supported but not recommended for new extensions.MessagesDirs for i18n
Point to directories containing JSON internationalization files:en.json, de.json, etc. Each file maps message keys to their localized strings:
Hooks and HookHandlers
Register hook handlers using the new-styleHookHandlers + Hooks pair:
ServiceWiringFiles
Register additional service wiring files:ResourceModules
Register JavaScript and CSS via ResourceLoader:localBasePath is relative to the extension root. remoteExtPath is relative to $wgExtensionAssetsPath on the client. Module names should use the ext.<extensionname>.<module> convention.
Complete Example
Extension Registration Internals
Theincludes/Registration/ directory contains the classes that process extension.json:
| File | Role |
|---|---|
ExtensionRegistry.php | Singleton registry; reads and caches extension data |
ExtensionProcessor.php | Parses extension.json and merges data into core |
ExtensionJsonValidator.php | Validates extension.json against the schema |
VersionChecker.php | Evaluates requires version constraints |
Processor.php | Base class for extension and skin processors |
Extension vs. Skin
Skins use the samewfLoadSkin() mechanism and a skin.json file with an identical structure. The type field in extension.json can be "skin", but conventionally skins use skin.json so they appear separately in Special:Version. See the Skins page for details.