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

OverviewEdit

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:

https://addshore.com/2021/11/mediawiki-docker-dev-in-mwcli/
https://gitlab.wikimedia.org/repos/releng/cli/-/releases
https://www.mediawiki.org/wiki/Cli

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/

PywikibotEdit

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:

user-config.py:

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

pywikibot/families/mwcli_family.py:

from pywikibot import family

# for local mw-cli dev wiki

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

/etc/hosts

I also found it necessary to add this to my /etc/hosts file (I'm on mac, FWIW).

127.0.0.1 proxy.mwdd.localhost
127.0.0.1 eventlogging.mwdd.localhost
127.0.0.1 adminer.mwdd.localhost
127.0.0.1 mailhog.mwdd.localhost
127.0.0.1 graphite.mwdd.localhost
127.0.0.1 phpmyadmin.mwdd.localhost
127.0.0.1 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.

Scripts

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

python3 pwb.py login.py

XDebugEdit

(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 https://www.mediawiki.org/wiki/Cli/guide/Docker-Development-Environment#Using_XDebug_for_MediaWiki) was the client host.

The docs I linked above suggested I could do something like mw docker env set MEDIAWIKI_XDEBUG_CONFIG "client_host=192.168.50.238" 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=192.168.50.238 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.