A little AppConfig tip

I have a little tip for AppConfig, one apparently not everyone knows, as I discovered in a household discussion.

The wonderfully useful module AppConfig reads ini files

[foo]
bar = 1
baz = 2

[herp]
derp = 4

and makes them accessible in a configuration object like so:

$cfg->foo_bar; # return 1
$cfg->foo_baz;
$cfg->herp_derp;

Now, if you want parameters not in any section, put those at the top of your config file. For $cfg->hork:

hork = 1
[foo]
bar = 1
..

If you put it lower down you’ll end up with $cfg->foo_hork or $cfg->herp_hork.

That is all. Carry on.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: