2017 © Pedro Peláez
 

library config

The Superatom Config package.

image

superatom/config

The Superatom Config package.

  • Saturday, May 9, 2015
  • by yusukezzz
  • Repository
  • 0 Watchers
  • 0 Stars
  • 77 Installations
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Superatom Config

A simple ReadOnly configuration library, (*1)

Install

Require this package in your composer.json, (*2)

"superatom/config": "dev-master"

Usage

example configuration file store to path/to/config/app.php
path/to/config dir contains only config files, (*3)

<?php // app.php

return [
    'debug' => true,
    'hoge' => 'fuga',
    'array' => [
        'key1' => 'val1',
        'key2' => 'val2',
    ],
    'environment' => env('ENV_NAME', 'default_value'),
    'bool_env' => env('DEBUG_MODE', false),
];

use app.php config example, (*4)

<?php
require_once 'path/to/vendor/autoload.php';

putenv('DEBUG_MODE=true');

$config = new \Superatom\Config\Repository('path/to/config');

// get config value by dot notation key

var_dump($config->get('app.debug'));
// bool(true)

var_dump($config->get('app.array.key1'));
// string(4) "val1"

// environment variables value is always string.
// but 'true' or 'false' string convert to PHP boolean value automatically.
var_dump($config->get('app.bool_env'));
// bool(true)

var_dump($config->get('app'));
/*
array(5) {
  'debug' =>
  bool(true)
  'hoge' =>
  string(4) "fuga"
  'array' =>
  array(2) {
    'key1' =>
    string(4) "val1"
    'key2' =>
    string(4) "val2"
  }
  'environment' =>
  string(13) "default_value"
  'bool_env' =>
  bool(true)
}
*/

helper function

env($name, $default = null), (*5)

return environment value if exists (supports boolean value), (*6)

License

MIT, (*7)

The Versions

09/05 2015

dev-master

9999999-dev

The Superatom Config package.

  Sources   Download

MIT

The Requires

 

by Avatar yusukezzz