Using configuration files with other formats than YAML
Hi, I've seen that Dancer can use just YAML configuration files and no other formats like JSON, ini, Apache or others. Are there specific reasons for this limitation? I use a short and dirty code that allows using all types of configuration files supported by Config::Any: use Dancer ':syntax'; use FindBin; use Config::Any; my $config = Config::Any->load_stems( { stems => [ "$FindBin::Bin/../config" ], flatten_to_hash => 1, use_ext => 1 } ); my @config = %$config; $config = $config[1]; set $_ => $config->{$_} for keys %$config; my $env = Config::Any->load_stems( { stems => [ "$FindBin::Bin/../environments/" . config->{environment} ], flatten_to_hash => 1, use_ext => 1 } ); my @env = %$env; $env = $env[1]; set $_ => $env->{$_} for keys %$env; After doing this I can use configuration files like config.yml, config.conf, config.pl... and environments/development.yml, environments/development.conf... each one with their specific format. In the code above I used just a single configuration file, but with a code just a little bit longer the app could get and use the vars defined in more files with the same name and different formats if it is needed, but that thing is probably not very useful. The question is, wouldn't be better if Dancer would use Config::Any in core? It would be more flexible and Config::Any doesn't require other modules. Those modules will be installed only by those who need them. --Octavian
On Thu, 18 Oct 2012 14:23:22 +0300 "Octavian Rasnita" <orasnita@gmail.com> wrote:
I've seen that Dancer can use just YAML configuration files and no other formats like JSON, ini, Apache or others. Are there specific reasons for this limitation? [...] The question is, wouldn't be better if Dancer would use Config::Any in core? It would be more flexible and Config::Any doesn't require other modules. Those modules will be installed only by those who need them.
Dancer2 does exactly that :) I don't think it's worth adding in Dancer1, to be honest - we're focussing on getting Dancer2 ready for primetime, and mostly avoiding new features in Dancer1 now. So, rest assured that Dancer2 will indeed support any config file that Config::Any can support :) -- David Precious ("bigpresh") <davidp@preshweb.co.uk> http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/cpan www.preshweb.co.uk/github
participants (2)
-
David Precious -
Octavian Rasnita