Custom Config Files

I always try to have stuff as predefined as possible, so you only need to upload your Kirby installation and that's it. But sometimes you really need or want to define your own custom config stuff. To keep that away from the core system, you've got a nice custom config folder in the site folder (site/config)

The main config file (site/config/config.php) already contains a lot of instructions how to change the available configuration. Please make sure to keep a backup of the default config file if something should go wrong.

Custom config variables

While you can adjust all the existing config variables if necessary, you can also set your own variables to use them later in your templates or plugins.

Setting your own variables in site/config/config.php couldn't be easier:

c::set('myvar', 'This is a nice variable');

Later in your template or plugin, get the content of that variable like this:

span class="st0">'myvar'); 
// should echo "This is a nice variable"

You can also define a default value if the variable is empty or not found:

span class="st0">'myunknownvar', 'This is my default content'); 
// should echo "This is my default content"

Multiple Hosts Setup

When you prefer to develop on your local machine before you upload your site to the web you probably sooner or later run into the problem of needing two different config files for this. Maybe you've got mod_rewrite on your local machine but not on your server or you need to set a different URL, or… There are plenty of reasons why multiple config files for different environments are awesome. I built that right into Kirby because I got that problem all the time and it sucks hard!!

Setting up different config files for different hosts is super easy. Let's say you got your local version running under the domain http://dev.yourawesomesite.com and your production version is running under the domain http://yourawesomesite.com. All you need to do is to add two more config files to site/config so the content of it will look like this:

site/config/config.php
site/config/config.dev.yourawesomesite.com.php
site/config/config.yourawesomesite.com.php

What kirby does is to load config.php first, so you can put all your global config customization there. Afterwards it will check for the domain and the matching config file and only append that. So you can overwrite some config vars in that specific domain config.