shazam/easy-config

Reads Yaml config files

Installs: 590

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 15

Forks: 4

Open Issues: 0

Type:helper

0.3.1 2016-08-18 13:07 UTC

This package is not auto-updated.

Last update: 2022-03-28 21:07:25 UTC


README

Simple PHP library to read from yaml files.

Usage

Place the following code in the constructor of your class or the superclass:

use EasyConfig\Config;

$config = Config::getInstance();
$config->setUseCache(false); //Default is true, so no need to specify if you want to use APC
$config->loadConfig(
    array(
        __DIR__ . '/../config/environment.yml',
        __DIR__ . '/../config/properties.yml'
    )
);

Somewhere else in your code you can load a config value, by calling $config->fetch() and the headings of the value:

$config = Config::getInstance();
$var = $config->fetch('heading', 'subheading');               //Fetches value under [heading][subheading]
$var = $config->fetch('heading', 'subheading', 'subheading'); //Fetches value under [heading][subheading][subheading]
$var = $config->fetch();                                      //Fetches the whole config

You can specify as many keys as you want when fetching config values.