Skip to content

Instantly share code, notes, and snippets.

@montehurd
Last active October 7, 2022 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save montehurd/64257440b03f36332214db62d8cf6814 to your computer and use it in GitHub Desktop.
Save montehurd/64257440b03f36332214db62d8cf6814 to your computer and use it in GitHub Desktop.
mediawiki-docker-basic-installations

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.

Fetch, install and start "Dockerized" MediaWiki instance

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.

Configure MediaWiki debugging in PHPStorm

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:

More

A more complex example, which also fetches and configures an extension and a patch, can be found here:

https://gist.github.com/montehurd/bf9e73100cc28f546b4ec4ae15869e6c

@montehurd
Copy link
Author

montehurd commented Jul 22, 2021

I updated the script, and it works on my Apple M1 machine, but I haven't re-tested the PHPStorm debugging bits...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment