Note: superceded by https://gitlab.wikimedia.org/mhurd/mediawiki-docker-make
I'm using this page to document experimentation with the new docker bits in Mediawiki core.
How to download, install and run a basic MediaWiki instance, from scratch, using Docker, and wire up PHPStorm debugging
These instructions are intended for someone who has no previous MediaWiki experience, who is interested in getting a basic instance of MediaWiki running on their local machine.
Steps tested on macOS - mileage may vary on other platforms.
The following steps work to very quickly fetch, install and run a basic MediaWiki instance, from scratch, based on the instructions found here.
These steps assume you do not already have a ~/mediawiki
folder on your system, and that it does not already have a service running on port 8080.
Step 1:
Install Docker and Docker Compose:
https://docs.docker.com/install/
https://docs.docker.com/compose/install/
Step 2:
Open Terminal (press Command-Spacebar to open Spotlight Search and type "terminal.app", and press return) and paste the following into the terminal window and press return.
cd ~
git clone https://github.com/wikimedia/mediawiki.git mediawiki --depth=1
git clone https://github.com/wikimedia/mediawiki-skins-Vector.git mediawiki/skins/Vector --depth=1
cd mediawiki
echo "MW_DOCKER_PORT=8080
MW_DOCKER_UID=$(id -u)
MW_DOCKER_GID=$(id -g)
MEDIAWIKI_USER=Admin
MEDIAWIKI_PASSWORD=dockerpass
XDEBUG_ENABLE=true
XHPROF_ENABLE=true
XDEBUG_CONFIG=''" > .env
docker-compose up -d
docker-compose exec --user="root" mediawiki composer self-update --2
docker-compose exec --user="root" mediawiki composer update
docker-compose exec --user="root" mediawiki /bin/bash /docker/install.sh
open "http://localhost:8080/wiki/Special:Version"
Installation should take between 5 and 10 minutes. When installation completes, if all goes well, a Safari window will open displaying the local MediaWiki installation's "Special:Version" page.
PHPStorm's debugger can be used to set breakpoints and inspect and step through MediaWiki's PHP code, but because we're using Docker some configuration is necessary.
Step: 1: Download and install PHPStorm:
https://www.jetbrains.com/phpstorm/
Step: 2:
Ensure the new ~/mediawiki
folder has been added to PHPStorm:
Select File > Open
and pick the mediawiki
folder in your user directory.
Step: 3:
Add a server
under Preferences > Languages & Frameworks > PHP > Servers
and choose settings similar to those in the image below:
Step: 4:
Create a Run / Debug configuration
by selecting Run > Edit Configurations...
, then tap +
, then select PHP Remote Debug
and choose the server
created in the previous step and enter an IDE key of PHPSTORM
:
Step: 5:
Tap this icon:
Debug!
Then you can try setting a breakpoint by tapping just to the right of a line number, for example, line 42 in index.php
:
Then refresh http://localhost:8080/index.php
in Safari. Execution should stop at line 42 of index.php
, and you should be able to use the debugger, for example, to step into wfEntryPointCheck
:
A more complex example, which also fetches and configures an extension and a patch, can be found here:
https://gist.github.com/montehurd/bf9e73100cc28f546b4ec4ae15869e6c
I updated the script, and it works on my Apple M1 machine, but I haven't re-tested the PHPStorm debugging bits...