2017 © Pedro PelĂĄez
 

library uconfig

A micro, no frills, configuration interface for PHP

image

flaviovs/uconfig

A micro, no frills, configuration interface for PHP

  • Tuesday, March 15, 2016
  • by flaviovs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

A micro configuration interface for PHP

Usage:, (*1)

$handler = new \UConfig\INIFileHandler('/path/to/config.ini');
$defaults = [
    'section' => [
        'bar' => 1,
        'zoo' => 2,
    ],
];
$config = new \UConfig\Config($defaults);
$config->addHandler(new \UConfig\INIFileHandler('/path/to/config.ini'));

$bar = $config->get('section', 'bar');
// $bar = 1

try {
    $config->get('nonexistent', 'bar');
} catch ( \UConfig\SectionNotFoundException $ex ) {
    die("Section not found: " . $ex->getMessage());
} catch ( \UConfig\OptionNotFoundException $ex ) {
    die("Option not found: " . $ex->getMessage());
}

Handlers

Configuration is handled by configuration handlers. To implement a new handler, add a class that implements the UConfig\Handler interface, with a method called load() that returns a configuration array, which must be structured as follows:, (*2)

 $config = [
     'section' => [
         'key1' => value,
         'key2' => value,
         //(...)
     ],
     'anothersection' => [
         'key1' => value,
         'key2' => value,
         //(...)
    ]
]

A UConfig\Config object may have many handlers attached to it. Use the addHandler() method to add handlers. Configuration is loaded in sequence, with later handler overriding previous ones., (*3)

Currently, only the UConfig\INIFileHandler is provided. Other handlers may be added in the future., (*4)

The Versions

15/03 2016

dev-master

9999999-dev

A micro, no frills, configuration interface for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by FlĂĄvio Veloso

15/03 2016

0.0.1

0.0.1.0

A micro, no frills, configuration interface for PHP

  Sources   Download

MIT

The Development Requires

by FlĂĄvio Veloso