Cli/guide/Docker-Development-Environment

A MediaWiki-Docker-Dev like developer environment.

First Setup
If you already have a LocalSettings.php file from a previous developer environment, see the LocalSettings.php section below before starting.

You can get started with a basic MediaWiki installation, first creating the needed services.

If this is your first time using the Cli then you will be guided through a setup wizard.

First setup might take some time as docker images, code and dependencies will be fetched.

And then performing a MediaWiki install.

You can choose to do a basic sqlite installation:

Or you can install using mysql:

The install command will output the location of your new wiki.

If you want multiple wikis, checkout the --dbname option.

LocalSettings.php
The development environment automatically sets various MediaWiki settings, such as database details. In order to do this it needs a "shim" at the top of your LocalSettings.php file.

When starting with a fresh install this will be created by the setup wizard.

If you already have a LocalSettings.php file, then you'll need to add the below snippet, removing any that may have been included from other environments.

MediaWiki Interaction
You can use the exec command to perform actions inside the MediaWiki container.

Such as, watching logs:

Or running PHPUnit tests:

MySQL Services
The "Initial setup" guide already walked you through creating a simple mysql wiki.

PHPMyAdmin & Adminer
PHPMyAdmin & Adminer are web interfaces for various databases.

You can easily run these as part of the development environment.

MySQL Replication
You can choose to add a mysql replica at any time. Replication will be handled automatically (but may take some time to catch up if you have already performed lots of actions).

Other services
All services follow similar patterns of create, suspend, resume, destroy.

Services will generally be automatically configured with MediaWiki when they are run.

Using XDebug for MediaWiki
The default XDebug mode is develop,debug, and the debugger will try to connect to localhost:9003.

If you want to alter the XDebug config you can do so using an environment variable.

It often makes sense to set the client_host to the public IP address of your physical device in your local network (i.e. wifi or ethernet IP).

You can set multiple xDebug config variables by leaving a space between them, for example:

Triggering for requests
See https://xdebug.org/docs/step_debug#activate_debugger

Example triggering from CLI inside the MediaWiki container:

Alter a container environment variable
If you want to alter an environment variable on a container, you'll need to re create the container after the change.

For example:

You should see that the container recreates:

Running PHPUnit tests
You can run PHPUnit tests with the executable that is inside the  directory in core. So, for example, if you're in the  directory and want to run a test in the an extension, then the command could look like the following:

You can also add environment variables, for example, if you want to make use of XDEBUG to step through a specific test in your IDE:

Using a different base docker image
You may want to use a different base image for your MediaWiki container. For example, you might want to use a different PHP version than the default. You can do so by setting the  environment variable: