mw-dev-kit
is a Docker-based development environment for MediaWiki that streamlines setup, management, and testing of
extensions and skins. It centralizes configuration, automates repository and database management, and provides a
powerful CLI tool (mwutil
) to handle common development tasks efficiently.
- .env centralizes options for MW, databases, mwutil etc.
- Comes with MySQL, MariaDB and ElasticSearch
- Fully containerized, only Docker is required on the host machine
- Fully integrated CLI tool (mwutil) with autocompletion
- Start/stop/recreate the containers
- Run phpcs, phan and phpunit
- Pull an extension or a skin with a simple command
- Reset and reinstall the entire MW installation (SQL + ElasticSearch) in seconds just by running
mwutil reset
- Autocompletion for maintenance script names
- Create security patches with a single command
- Automatically set up gerrit repositories locally
- Create and import database dumps in seconds with a simple command
- Switch between MySQL and MariaDB
- Many convenient functions for extensions, skins and configurations
- Autoloading of dependent extensions
- Automatic deduplication of skins/extensions through a custom loader
- Polyfill function for class aliases
- Support for XDebug by default
This project is made for:
- developers who work on a lot of extensions but still want to have a clean environment
- security researchers who want to set up an extension and its dependencies as fast and easily as possible while still fully retaining control over the environment
This project is not made for
- production environments (please don't!)
Requirements:
- Have docker installed (Fedora: https://docs.docker.com/engine/install/fedora/)
- Enable using docker as non-root (https://askubuntu.com/a/477554)
- Have
git-review
installed (Fedora:sudo dnf install git-review
)
- Clone this repo into a folder and cd into it.
cp ./config/.env.example ./config/.env
- Edit
./config/.env
and customize the options. At leastMEDIAWIKI_PASSWORD
,DB_ROOT_PASSWORD
,CHANGE_ME
,MW_SECRET_KEY
and the git/gerrit sections should be changed - Clone core using SSH:
git clone ssh://<username>@gerrit.wikimedia.org:29418/mediawiki/core
(replace<username>
with your gerrit username) ln core-composer.local.json core/composer.local.json
- Setup mwutil if you haven't yet
- Create an empty mwutil config file:
echo "{}" > .mwutil.json
- Start the containers:
mwutil up
- Install the dependencies:
mwutil bash composer install
- Create a default LocalSettings.php file:
cp LocalSettings.default.php LocalSettings.php
ln LocalSettings.php core/LocalSettings.php
- Install MediaWiki (this is done by resetting the installation):
mwutil reset
- Set up the origin and git config for MW core, if you want to contribute to it later:
cd core && mwutil setup-gerrit
- Clone Vector, so you can use it:
mwutil clone skin gerrit Vector --quick --branch <MW Branch>
(note:--quick
creates a shallow clone; if you plan to contribute to Vector, consider removing the parameter to fully clone it) - Visit
localhost:4001
in your browser
PHPStorm configuration:
Private functions and settings can be added to the "MWCPrivate" trait, which should be created inside an " MWCPrivate.php" file. This file will automatically be loaded if available, and will not be added to git, as it's listed in .gitignore. (This is mostly useful for people like me who contribute to this repository and don't want to accidentally commit private settings)