Skip to content

Develop a MediaWiki extension

Releasev0.35.0 · cfeceb67

Watch it in action

Add and test a MediaWiki extension

Use mw dev mediawiki get-code to add an extension to the checkout used by your selected development context:

Terminal window
mw dev mediawiki get-code --extension Cite

The default Gerrit clone method uses SSH. Configure your Gerrit username first, or use --gerrit-interaction-type http --no-commit-hook for an anonymous public clone when you do not need to push changes.

Fetching the source does not enable the extension. Add it to LocalSettings.php after the shared development settings:

wfLoadExtension( 'Cite' );

Run the updater when an extension needs database changes, then run a focused PHPUnit test from its directory:

Terminal window
mw dev mediawiki mwscript update
mw dev mediawiki composer phpunit extensions/Cite/tests/phpunit/unit/CiteParserTagHooksTest.php

If the test fails, inspect the MediaWiki service logs and repeat the test after the fix:

Terminal window
mw dev compose logs -- --tail=40 mediawiki
mw dev mediawiki composer phpunit extensions/Cite/tests/phpunit/unit/CiteParserTagHooksTest.php

The example uses Cite, but the same loop applies to other extensions and skins. Check the extension’s own README for required Composer dependencies, configuration and test commands. See MediaWiki configuration and service management for more details.


Read this guide offline with mw help guides dev extension-workflow.

Report an issue with this page

Report a documentation issue

The report includes this page’s link, section and documentation version.

Review and submit on Phabricator, or run the command using your saved CLI profile. The command asks before creating the task.