2017 © Pedro Peláez
 

library puja-config

Allow load multi configured files, access the configured value as an object

image

jinnguyen/puja-config

Allow load multi configured files, access the configured value as an object

  • Friday, November 4, 2016
  • by jinnguyen
  • Repository
  • 1 Watchers
  • 0 Stars
  • 23 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

puja-config v1.0.0

Allow load multi configured files, access the configured value as an object, (*1)

Install:
, (*2)

composer require jinnguyen/puja-config

Usage:
, (*3)

require 'path/to/vendor/autoload.php';

Example:

Folder tree:, (*4)

root/
root/app/configure.php
root/app/configure_local.php
root/config/configure.php
root/config/configure_local.php

File root/config/configure.php
, (*5)

$configures['database'] = array(
    'host' => 'localhost',
);
$configures['app_name'] = 'Puja/Config';

File root/config/configure_local.php, (*6)

$configures['database'] = array(
    'host' => 'remote_host',
);

File root/app/configure.php, (*7)

$configures['session'] = array(
    'savePath' => '/tmp',
);

File root/app/configure_local.php, (*8)

$configures['session'] = array(
    'savePath' => '/home/tmp',
);

File root/demo.php:, (*9)

include 'path/to/vendor/autoload.php';
use Puja\Configure\Configure;
new Configure(array('config/', 'app/'));


$databaseCfg = Configure::getInstance('database');
echo $databaseCfg->get('host'); // remote_host

$sessionCfg = Configure::getInstance('session');
echo $sessionCfg->get('savePath'); // /home/tmp

$allCfg = Configure::getInstance();
echo $allCfg->get('app_name'); // Puja/Config

Note

new Configure(array('config/', 'app/')); is same with, (*10)

require config/configure.php
require config/configure_local.php
require app/configure.php
require app/configure_local.php

So the values from configure_local.php will overwrite configure.php in same folder, the last folder will overwrite the previous folder., (*11)

The Versions

04/11 2016

dev-master

9999999-dev

Allow load multi configured files, access the configured value as an object

  Sources   Download

Apache License 2.0

by Jin Nguyen

configuration config configure puja

04/11 2016

v1.0.0

1.0.0.0

Allow load multi configured files, access the configured value as an object

  Sources   Download

Apache License 2.0

by Jin Nguyen

configuration config configure puja