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

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search


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/


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):



(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?

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 /etc/php/7.3/fpm/conf.d/20-xdebug.ini file

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 search for "xdebug" and you can see what settings your wiki is running with.