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'll then have a MediaWiki install running on SQLite accessible at http://default.mediawiki.mwdd.localhost:8080/



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.

MySQL Setup
You'll then have a MediaWiki install running on MySQL accessible at http://mysqlwiki.mediawiki.mwdd.localhost:8080/

If you want to see the database in a UI, try using the adminer or phpmyadmin services.

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: