2017 © Pedro Peláez
 

library config

Lightweight Config Registry

image

krak/config

Lightweight Config Registry

  • Monday, May 1, 2017
  • by ragboyjr
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Config

The Config library provides a simple interface for adding configuration values. All config files are loaded lazily only when invoked providing a clean yet efficient way of managing config., (*1)

Installation

Install with composer at krak/config, (*2)

Usage

All Config is managed via the ConfigStore. Config\store provides a default instance which will lazy load files/data and will cache the results to prevent multiple filesystem calls., (*3)

Adding Config Items

Adding multiple entries under the same key will merge the data when it's retrieved. The entries added last will overwrite the previous entries., (*4)

<?php

$config = Krak\Config\store();
// add array data
$config->add('a', [
    'from_array' => true,
    'b' => ['c' => 1]
]);
$config->add('a', function() {
    return ['from_closure' => true],
});
// You can add, php, ini, json, or yml files, but you must provide the full path
$config->add('a', __DIR__ . '/path/a.php');

// or you can use this helper for files
$config->addFiles(__DIR__ . '/path', [
    'a.php',
]);
$config->addPhpFiles(__DIR__ . '/path', ['a']); // this is the exact same as above

PHP configuration files must return an array like so:, (*5)

<?php

return [
    'from_php_file' => true
];

Note: For YAML files, you must install the Symfony YAML Component (symfony/yaml)., (*6)

Getting Config Items

<?php

var_dump($config->get('a'));

// or retrieve nested items
$config->get('a.b.c');

This will display something like:, (*7)

array(4) {
  ["from_array"]=>
  bool(true)
  ["from_closure"]=>
  bool(true)
  ["from_php_file"]=>
  bool(true)
}

The Versions

01/05 2017

dev-master

9999999-dev

Lightweight Config Registry

  Sources   Download

MIT

The Development Requires

01/05 2017

v0.1.0

0.1.0.0

Lightweight Config Registry

  Sources   Download

MIT

The Development Requires