[Dancer-users] Sharing config files

David Precious davidp at preshweb.co.uk
Tue Nov 15 11:42:21 CET 2011


On Tuesday 15 November 2011 09:01:52 Stephen Fenwick-Paul wrote:
> Hi
> 
> I have 2 Dancer apps, one a web site and another a RESTful api, both
> connecting to the same database
> 
> At the mo they each have their own config.yml,  but as so much
> configuration detail between them is common it would be great to have a
> central configuration for the common stuff and then a config for the
> relatively few things unique to the app.
> 
> Any ideas how achieve such a regime?

Currently I don't know of a particularly clean way, but that's something I'd 
like to see - a "merge config" option to allow you to load other config files 
and merge their content into the app's config.

In the meantime, you could store your database settings in a separate YAML 
file, then in your apps, load that and put it into the app's config with 
something a little like:

    my $db_conf = YAML::LoadFile('database.yml');
    config->{plugins}{Database} = $db_conf;

That should work :)


-- 
David Precious  ("bigpresh")
http://www.preshweb.co.uk/

   "Programming is like sex. One mistake and you have to support
   it for the rest of your life". (Michael Sinz)


More information about the Dancer-users mailing list