Dead-simple configurations

dev-master 2013-03-17 20:08 UTC

This package is not auto-updated.

Last update: 2024-12-21 16:10:16 UTC


README

Fig - Dead-simple configurations

Build Status

Using Fig is stupidly easy. Install with Composer:

{
	"require": {
		"dannykopping/fig": "dev-master"
	}
}

To initialize a set of configuration options:

use Fig\Fig;

require_once "vendor/autoload.php";

Fig::setUp(array(
        "name" => "Fig",
        "multiple" => array(
            "levels" => array(
                "of" => "nesting goodness"
            )
        )
    )
);

To access your configuration options, either use simple strings for top-level keys:

echo Fig::get("name");  // prints "Fig"

...or use dot-notation to indicate hierarchy:

echo Fig::get("multiple.levels.of");  // prints "nesting goodness"

Oh - you want to set values, too?

Fig::set("year", 2013);
echo Fig::get("year");  // prints "2013" (and maintains your data types)

...even multi-level values!

Fig::set("calendar.years", array(2010,2011,2012,2013));
echo implode(", ", Fig::get("calendar.years"));  // prints "2010, 2011, 2012, 2013"

Wanna get rid of a bad fig?

Fig::delete("year");
echo Fig::get("year");  // prints null, key is removed

All your figs?

print_r(Fig::getAll());