This is my approach:

I have one config file that the app always reads, independently of the current run mode.

It's in JSON, but that's not really import - import is that you can have nested hashes. It looks like this, when written as Perl data structure:

my $conf = { app_home => '/path/to/app/', other_key => 'other_value', dev => { app_home => '/other/path', }, prod => { other_key => 'foo bar', }, };

Now when I ask my app for a config value, it first looks up in the sub hash of the same keys as the current run mode (dev, test, prod, staging, ...), and if it doesn't exist, it falls back to the same key at the top level hash.

(This is roughly the same as having a general config file, and separate config files for each runmode, but it saves you the pain of having separate paths for them).

I determine the run mode by environment variables, and for example the tests automatically set it test.


In reply to Re: Development config files by moritz
in thread Development config files by willymacoy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.