2017 © Pedro Peláez
 

library config

Simple Config Reader

image

simplon/config

Simple Config Reader

  • Friday, November 22, 2013
  • by fightbulc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 407 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

     _                 _                                __ _       
 ___(_)_ __ ___  _ __ | | ___  _ __     ___ ___  _ __  / _(_) __ _ 
/ __| | '_ ` _ \| '_ \| |/ _ \| '_ \   / __/ _ \| '_ \| |_| |/ _` |
\__ \ | | | | | | |_) | | (_) | | | | | (_| (_) | | | |  _| | (_| |
|___/_|_| |_| |_| .__/|_|\___/|_| |_|  \___\___/|_| |_|_| |_|\__, |
                |_|                                          |___/ 

Simplon Config

Its a simple config file reader which handles namespaced config arrays., (*1)

Config file example

$app = [
  'url'      => [
    'service'  => '[URL_SERVICE]',
    'frontend' => '[URL_FRONTEND]',
  ],

  'database' => [
    'mysql' => [
      'localhost' => [
        'server'   => 'localhost',
        'database' => 'some_db',
        'username' => 'rootuser',
        'password' => 'rootuser'
      ]
    ],
  ],
  'email'    => [
    'host' => 'localhost',
    'port' => 25,
  ],
];

Get data from your config file

To safe resources we access the config class via singleton pattern Config::getInstance(). By passing the config file path we inform the class which file we want to read. Now, in order to fetch an actual value we pass an existing config array index as array to getConfigKeys(['url']). As a result we would receive all values which are within the array index of url:, (*2)

[
  'service'  => '[URL_SERVICE]',
  'frontend' => '[URL_FRONTEND]',
];

Multiple array elements will be chained together. According to that the following example will only return the string value for ['url']['service']:, (*3)

use Simplon\Config\Config;

$configPath = __DIR__ . '/../../config/common.config.php';

$urlService = Config::getInstance()
->setConfigPath($configPath)
->getConfigByKeys(['url', 'service']);

echo $urlService; // prints "[URL_SERVICE]"

The Versions

22/11 2013

dev-master

9999999-dev https://github.com/fightbulc/simplon_config

Simple Config Reader

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Tino Ehrich

config reader

22/11 2013

0.6.0

0.6.0.0 https://github.com/fightbulc/simplon_config

Simple Config Reader

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Tino Ehrich

config reader

13/03 2013

0.5.2

0.5.2.0 https://github.com/fightbulc/simplon_config

Multi Environment PHP-Config Reader

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Tino Ehrich

config

07/03 2013

0.5.1

0.5.1.0 https://github.com/fightbulc/simplon_config

Multi Environment PHP-Config Reader

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Tino Ehrich

config

18/10 2012

0.5.0

0.5.0.0 https://github.com/fightbulc/simplon_config

Multi Environment PHP-Config Reader

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Tino Ehrich

config