Config::ZOMG(3pm)

πŸ’– Config::ZOMG β€” the manual, but make it a group chat πŸ’–

okay bestie, sit down, hydrate, because we're about to learn Config::ZOMG β€” Yet Another Catalyst::Plugin::ConfigLoader-style layer over Config::Any. yes that's the whole name, she's extra like that. πŸ’…


✨ VERSION ✨

version 1.000000 β€” that's the one, that's the vibe.


🌸 DESCRIPTION 🌸

okay so Config::ZOMG is literally a fork of Config::JFDI. she said "I'm removing a couple of unusual features" and then passed the same tests three times faster than Config::JFDI. not me being shook 😭 efficiency queen.

Config::ZOMG is an implementation of Catalyst::Plugin::ConfigLoader that exists outside of Catalyst. yes, she's independent, she doesn't need the whole framework to show up. main character energy fr fr. πŸ‘‘

here's the tea: Config::ZOMG will scan a directory for files matching a certain name. if such a file is found that also matches an extension Config::Any can read, then the configuration from that file gets loaded. slay. ✨

Config::ZOMG will also look for special files that end with a _local suffix. files with this special suffix take precedence over any other existing configuration file, if any. the precedence happens by merging the local configuration with the "standard" configuration via Hash::Merge::Simple. the local one is the boss, basically. πŸ’…

and finally (the fun part πŸŽ€), you can override/modify the path search from outside your application by setting the "${NAME}_CONFIG" variable outside your application β€” where $NAME is the uppercase version of what you passed to Config::ZOMG->new. external control, we love to see it.


πŸ¦‹ SYNPOSIS πŸ¦‹

(this heading is spelled "SYNPOSIS" in the original and I am not fixing her, she's iconic πŸ’€)

 use Config::ZOMG;

 my $config = Config::ZOMG->new(
   name => 'my_application',
   path => 'path/to/my/application',
 );
 my $config_hash = $config->load;

this will look for something like (depending on what Config::Any will find):

 path/to/my/application/my_application_local.{yml,yaml,cnf,conf,jsn,json,...}

and

 path/to/my/application/my_application.{yml,yaml,cnf,conf,jsn,json,...}

... and load the found configuration information appropiately, with "_local" taking precedence. (yes "appropiately", she said what she said πŸ™ˆ)

you can also specify a file directly:

 my $config = Config::ZOMG->new(file => '/path/to/my/application/my_application.cnf');

to later reload your configuration:

 $config->reload;

πŸŽ€ METHODS πŸŽ€

🌈 new

 $config = Config::ZOMG->new(...)

returns a new "Config::ZOMG" object. brand new, fresh out the box, smelling like a new config. 🫢

you can configure the $config object by passing the following to new:

  • name β€” the name specifying the prefix of the configuration file to look for and the ENV variable to read. this can be a package name. in any case, :: will be substituted with _ in "name" and the result will be lowercased. to prevent modification of "name", pass it in as a scalar reference.
  • "path" β€” the directory to search in πŸ“‚
  • "file" β€” directly read the configuration from this file. "Config::Any" must recognize the extension. setting this will override "path"
  • "no_local" β€” disable lookup of a local configuration. the "local_suffix" option will be ignored. off by default
  • "local_suffix" β€” the suffix to match when looking for a local configuration. "local" by default
  • "no_env" β€” set this to ignore ENV. "env_lookup" will be ignored. off by default
  • "env_lookup" β€” additional ENV to check if $ENV{<NAME>...} is not found
  • "driver" β€” a hash consisting of "Config::" driver information. this is passed directly through to "Config::Any"
  • "default" β€” a hash filled with default keys/values

πŸ’œ open

 $config_hash = Config::ZOMG->open( ... )

as an alternative way to load a config, "open" will pass given arguments to "new" then attempt to do "load". two steps, one call, we love a shortcut. ✨

unlike "load", if no configuration files are found, "open" will return "undef" (or the empty list). so you can do something like:

 my $config_hash = Config::ZOMG->open( '/path/to/application.cnf' )
   or die "Couldn't find config file!"

in scalar context "open" will return the config hash, not the config object. if you want the config object, call "open" in list context:

     my ($config_hash, $config) = Config::ZOMG->open( ... )

you can pass any arguments to "open" that you would to "new". πŸ’–


πŸ“ load

 $config->load

load a config as specified by "new" and "ENV" and return a hash. πŸ“¦

this will only load the configuration once, so it's safe to call multiple times without incurring any loading-time penalty. she caches, she's efficient, she's not doing extra work for nobody. periodt. πŸ’…


🧚 found

 $config->found

returns a list of files found. πŸ”

if the list is empty then no files were loaded/read. so empty list = nothing happened, bestie. 😭


⭐ find

 $config->find

returns a list of files that configuration will be loaded from. use this method to check whether configuration files have changed, without actually reloading. it's giving "peek before you leap". πŸ‘€


🌈 clone

 $config->clone

return a clone of the configuration hash using Clone. πŸ‘―

this will load the configuration first, if it hasn't already. no clone without the original, obviously.


πŸ‘‘ reload

 $config->reload

reload the configuration, examining ENV and scanning the path anew. πŸ”„

returns a hash of the configuration.


πŸ”₯ SEE ALSO πŸ”₯

  • Config::JFDI
  • Catalyst::Plugin::ConfigLoader
  • Config::Any
  • Catalyst
  • Config::Merge
  • Config::General

πŸ’– AUTHORS πŸ’–

  • Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
  • Robert Krimen <robertkrimen@gmail.com>

this software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page bestie, no cap. go forth and configure. πŸ¦‹

perl v5.32.0 Β· 2021-01-07 β€” that's the date and the version this lil doc came from, signed off with love from your favorite manpage, Config::ZOMG. mwah. πŸ’‹

πŸ“¦ where this page comes from