Esteemed Monks,

We support some fairly complex web applications and lately we're running into some issues with our config infrastructure. I got some help recently when I asked What config info belongs where for web apps?; thanks to those who responded.

Now I'm trying to define a better config system, but I can't find any best practices or guidelines beyond simple config file processing.

Here are my needs:

Here's a draft of a best practice (untested), with many questions:

### Shared config info -- "machine scope" ### # A local module that loads the shared config info. # Is there a way to pass in a project name in a 'use' # that is mod_perl safe? use My::LocalConfig qw(project_name); ### App-specific config info -- "machine scope" ### # Assuming 'config_path' is a function exported by the LocalConfig mod +ule. # Or should it just set a variable? # What sort of variable and where can it be set so it's ready when # the require runs? # Would a 'do' be better? # Should the project_name be passed in here as a parameter? require config_path . "/my_config.pl"; # Or should we use a Config module here? # Do various config modules allow a function call when you set # the path? # Are there Config modules that allow some logic in them? # We have several cases where we set # variables differently based on dev, QA, or prod environments. ### Session config info -- "session scope" ### # A module that just grabs relevant $ENV info and # provides it via a method or methods. use My::SessionConfig; # then my $session = My::SessionConfig->new(); my $current_userid = $session->current_user();

What are you doing for your config environment?

Do you have custom modules to handle all of this?

Once I nail down the best practice or a functioning system, I'd like to follow some of TheDamian's advice and hide a bunch of this to make it easier to use. But we've already been burned by some cleverness in our mod_perl environment, so I'll want to be careful.


In reply to Configuration Best Practices for Web Apps by cbrandtbuffalo

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.