User:ATomasevich (WMF)/Local Development Tips

The following are local development environment setup instructions and tips somewhat specific to Structured Data.

Setup and basic usage
For those who want to use Docker, you have a couple of options:


 * 1) Use addshore's Mediawiki docker dev repo
 * 2) Use Monte's SDC-specific fork

The latter has an extended setup script that sets up various extensions needed for SDC development. I would highly recommend using it, or at least reviewing the setup script to see what you need. Follow the instructions in the README to get things set up, then add a few more extensions and LocalSettings config:


 * CommonsMetadata
 * MultimediaViewer
 * ParserFunctions
 * Scribunto
 * TemplateData
 * TemplateStyles

You should clone these from Gerrit, not GitHub, so you can easily pull the latest version if needed.

Add the extensions to your  file (see the end of this page for my LocalSettings file). Next, from the root of the docker dev repo, run  to run commands on the webserver. into the directory of each of the 6 extensions you just installed and run.

Docker commands
See the original Docker repo's README for a list of Docker commands you can run via scripts (like we just did to shell into the container via ).

Refreshing your local environment
When you pull updates for extensions you'll want to run  in that extension's directory. You can also run database updates by shelling in and running.

When pulling new code for Wikibase you'll also need to pull its subprojects by running.

Special pages
There are various "special" pages that aren't created like normal wiki pages, but rather are created via code within Mediawiki or an extension. You can view a list of them all at Special:SpecialPages (this link goes to the local version if you're using the D0cker setup).

Importing content
You can export content from other wikis and import them to your local instance. Note that this doesn't work great with large files.


 * Export: Visit Special:Export e.g. https://commons.wikimedia.org/wiki/Special:Export. Add pages via their titles, like File:Filename.jpg.
 * Import: Go to http://default.web.mw.localhost:8080/mediawiki/index.php?title=Special:Import. Be sure to include the prefix of the wiki you exported from, e.g. commons.

Xdebug
See instructions at the end of Monte's README for instructions on setting up Xdebug with PhpStorm or vscode. You'll also need the Xdebug Helper extension. Note that my path mapping value is slightly different from the README:

Front-end debug mode
Add the query parameter  to run Resource Loader in debug mode, which will stop it from minifying and concatenating your front-end assets.

Localisation
You can add the query parameter  with any language code to view a page in that language. You can also use the language code  which will turn all language strings into the message key that defines them, which is useful for figuring out where specific messages come from.

Miscellaneous tips

 * MacOS users: add the following to your  file to use your keychain to store your Gerrit passphrase:


 * You can experiment with the Mediawiki API on Special:ApiSandbox
 * Test a single phpunit file: