Manual:Configuration for developers


 * For documentation about configuring MediaWiki, see Manual:Configuration.

This is a guide for core and extension developers on the new way to access configuration settings.

Starting with MediaWiki 1.23, there is a new  interface to access configuration options. This will allow us to abstract the backend in which we store configuration options.

Pre-1.23 code would look like:

1.23+ code should look like this:

You'll notice a few changes here:
 * We use  to get the default   object. Most contexts implement.
 * Rather than checking for "wgFoo", you ask the Config object for "Foo", without any wg prefix.

If you don't have access to any ContextSources, you can get a Config object with

This should not be used to fetch global variable objects such as or.

For extensions
If you are using the  file (recommended), use the following:

If you are NOT using the  file (old-style), use the following:

Custom prefixes
In the past, some extensions used "eg" instead of "wg". We want to move away from prefixes, but you can still continue to use them:

Testing
When debugging, you use the following to test that you are accessing the right config instance. You should do this in place of the $wgConfigRegistry shown in the for extensions section.

If you are accessing the wrong config instance, a ConfigException will be produced.