User:BPirkle (WMF)/Stuff/Local Dev/MwCli

Overview edit

As of 2021-12-13, I'm still working out the details on this one. Most of it so far is a fairly standard mwcli install. Relevant info here:

This gave me a working instance at: http://default.mediawiki.mwdd.localhost:8080/w/index.php?title=Main_Page

With phpmyadmin available at: http://phpmyadmin.mwdd.localhost:8080/

Pywikibot edit

The first thing I'm doing with this install is playing around with manipulating it via Pywikibot. As of this writing, I haven't gotten very far, but I have managed to get pywikibot to log in. My config looks like this:

mylang = 'en'
family = 'mwcli'
usernames['mwcli']['en'] = 'admin'


from pywikibot import family

# for local mw-cli dev wiki

class Family(family.Family):
    name = 'mwcli'
    langs = {
        'en': 'default.mediawiki.mwdd.localhost:8080/',


I also found it necessary to add this to my /etc/hosts file (I'm on mac, FWIW). proxy.mwdd.localhost eventlogging.mwdd.localhost adminer.mwdd.localhost mailhog.mwdd.localhost graphite.mwdd.localhost phpmyadmin.mwdd.localhost default.mediawiki.mwdd.localhost

I could load mwcli pages in the browser okay without those lines added, but pywikibot wouldn't connect to my local wiki.


And then to log in, I do (from the command line, in my pywikibot/core directory):


XDebug edit

(What follows is a cut-and-paste from Slack. Maybe I'll make it more presentable later, but for now I just wanted to preserve the info.)

Got xdebug working on mwcli. The critical setting of interest (as suggested at was the client host.

The docs I linked above suggested I could do something like mw docker env set MEDIAWIKI_XDEBUG_CONFIG "client_host=" to set that, but for whatever reason that didn't work for me, even after suspending and resuming the container. Maybe destroying and recreating it would have worked? (Update: I tried again a few months later, and this command worked without doing the things below.)

Instead, I opened a terminal into the container with mw docker mediawiki exec --user root -- bash and then added the line xdebug.client_host= to the file /etc/php/7.3/fpm/conf.d/20-xdebug.ini

Then I tried to restart php-fpm via service restart php7.3-fpm, but because php-fpm was the master service for the container, that shut down the container. So I restarted it with mw docker mediawiki resume

Because that IP is specific to the current configuration of my local network, I'll have to update it if I'm working from somewhere else, or even just if my router assigns me a different IP.

One more trick: if you're not sure what settings are actually being applied, you can add phpinfo() to your index.php file, just above the wfIndexMain(); call and it'll dump all the php settings to the output of your wiki pages. It'll be super ugly, but who else is looking at your local, right? Search for "xdebug" and you can see what settings your wiki is running with.

Wiki Farm edit

mwcli makes it very very easy to create multiple wikis. Here's the command I ran to create a second wiki in my mwcli installation:

mw docker mediawiki install --dbtype=mysql --dbname=wiki2

I copied my LocalSettings.php file out in case mwcli messed with it, but it didn't. Probably still a good idea in case that ever changes.

Here's what I put in my LocalSettings.php to get different logos for each wiki, so I could easily tell my wikis apart at a glance:

if ( $wgSitename == 'mwdd-wiki2' ) {
	$wgLogos = [
		'1x' => "",
		'icon' => ""
} else {
	$wgLogos = [
		'1x' => "",
		'icon' => "",