This is a fork of MediaWiki-Docker-Dev with a script which simplifies setup of a "Dockerized" Mediawiki Structured Data on Commons development environment. ( manual setup instructions are pretty complicated )
Install Docker:
On MacOS you can use homebrew to install Docker using the command brew install docker
.
Other platform installation packages can be found here: https://docs.docker.com/install/
To install, clone this repo, then from the console, in the directory of the downloaded repo, run the setup script using a command like the following (first changing 'mm' to the desired install directory - this is the folder where Mediawiki and various extensions will be cloned):
INSTALL_DIR=~/mm ./setup.sh
Installation will take a few minutes.
To see if it worked, in a browser load:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special:Version
If you scroll down you should see WikibaseMediaInfo
under Installed extensions
.
If the link in the step above doesn't work, you may need to manually edit /etc/hosts
(i.e. sudo atom /etc/hosts
) adding the following lines:
127.0.0.1 default.web.mw.localhost # mediawiki-docker-dev 127.0.0.1 proxy.mw.localhost # mediawiki-docker-dev 127.0.0.1 phpmyadmin.mw.localhost # mediawiki-docker-dev 127.0.0.1 graphite.mw.localhost # mediawiki-docker-dev
Steps to add some structured data and associate it with an image.
In browser load Special:SpecialPages
:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special:SpecialPages
There should be Wikibase
section near the bottom now.
Click Create a new Item
link:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special:NewItem
Create a San Francisco
item (set Label
to San Francisco
). Should see Q1
to right of San Francisco
after you save it.
In browser load Special:SpecialPages
again:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special:SpecialPages
Click Create a new Property
link:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special:NewProperty
set Label
to depicts
set Description
to something like what is shown in image
set Data type
to Item
Should see P1
to right of depicts
after you save it - this is the P1
referred to in mediawiki/LocalSettings.php
where it says:
$wgMediaInfoProperties = [ 'depicts' => 'P1', ];
Load main page:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Main_Page
Log in:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special:UserLogin&returnto=Main+Page
Admin dockerpass
Upload any image file:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special:Upload
After upload there should be a Structured data
tab to right of File Information
below the image.
Tap the Structured data
tab, then tap Edit
, then begin typing San Francisco
and you should see the Q1
item we created earlier.
To configuring PHPStorm
to work with Xdebug
, you'll need to add a server
under Preferences > Languages & Frameworks > PHP > Servers
. Choose settings similar to those in the image below:
Then create a Run / Debug configuration
. Tap Run > Edit Configurations...
, then tap +
, then select PHP Remote Debug
and choose the server
created in the first image and enter an IDE key of PHPSTORM
:
Next tap this icon:
Note: on non-MacOS hosts you will probably need to change the IDELOCALHOST
value in /mediawiki-docker-dev-sdc/local.env
to your machine's local IP address. After changing it you'll need to restart the Docker bits by running ./destroy
then ./create
in /mediawiki-docker-dev-sdc
. This is not ideal as your local IP address can change. If you know a better way to handle this please let me know or open a PR :)
Go to the "Debug" menu and choose "Open Configuration". Then choose "PHP" (you need the PHP Debug extension installed first).
Doing this will create a launch.json
file in the .vscode
folder inside your workspace. Most of the contents below are generated automatically, but path mappings need to be added explicitly:
First, cd
to the mediawiki-docker-dev-sdc
directory, then run a command like the following, changing tests/phpunit/unit/includes/content/JsonContentHandlerTest.php
to the path of the php test file you want to execute:
./phpunit-file default tests/phpunit/unit/includes/content/JsonContentHandlerTest.php
Load the Special:JavaScriptTest
page:
http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special%3AJavaScriptTest&debug=true
If the Docker containers stop unexpectedly, you can run ./create
to restart them. See the parent repo readme's Commands section.