2017 © Pedro Peláez
 

library config

PHP configurations loading

image

jenner/config

PHP configurations loading

  • Friday, May 15, 2015
  • by huyanping
  • Repository
  • 2 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

Config

Build Status Latest Stable Version Total Downloads License, (*1)

PHP configurations loading library. It is made to enable your application to have different configurations depending on the environment it is running in. For example, your application can have different configurations for unit tests, development, staging and production. A good practice would be to not include your production or staging configurations in your version control. To do this, simply add a .gitignore file to your configs/environment directory with the following lines:, (*2)

*
!.gitignore

Requirements

This library uses PHP 5.3+., (*3)

Installation

It is recommended that you install the Config library through composer. To do so, add the following lines to your composer.json file., (*4)

{
    "require": {
       "sinergi/config": "dev-master"
    }
}

Usage

Setup the configurations directory:, (*5)

use Sinergi\Config\Config;

$config = new Config(__DIR__ . "/configs");

Optionally, you can also setup the environment. Setting up the environment will merge normal configurations with configurations in the environment directory. For example, if you setup the environment to be prod, the configurations from the directory configs/prod/* will be loaded on top of the configurations from the directory configs/*. Consider the following example:, (*6)

$config->setEnvironment('prod');

You can than use the configurations like this:, (*7)

$config->get('app.timezone');

Getter

The configuration getter uses a simple syntax: file_name.array_key., (*8)

For example:, (*9)

$config->get('app.timezone');

You can optionally set a default value like this:, (*10)

$config->get('app.timezone', "America/New_York");

You can use the getter to access multidimensional arrays in your configurations:, (*11)

$config->get('database.connections.default.host');

Setter

Alternatively, you can set configurations from your application code:, (*12)

$config->set('app.timezone', "Europe/Berlin");

You can set entire arrays of configurations:, (*13)

$config->set('database', [
    'host' => "localhost",
    'dbname' => "my_database",
    'user' => "my_user",
    'password' => "my_password"
]);

Examples

See more examples in the examples folder., (*14)

Example of a configuration file:, (*15)

return [
    'timezone' => "America/New_York"
];

The Versions

15/05 2015

dev-master

9999999-dev https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

config management loading configurations

20/10 2014

dev-develop

dev-develop https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

config management loading configurations

20/10 2014

0.5.0

0.5.0.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

config management loading configurations

09/07 2014

0.4.3

0.4.3.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations

22/04 2014

0.4.2

0.4.2.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations

22/04 2014

0.4.0

0.4.0.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations

16/01 2014

0.3.0

0.3.0.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations

30/12 2013

0.2.2

0.2.2.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations

30/12 2013

0.2.1

0.2.1.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations

30/12 2013

0.2.0

0.2.0.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations

26/12 2013

0.1.1

0.1.1.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations

26/12 2013

0.1.0

0.1.0.0 https://github.com/sinergi/config

PHP configurations loading

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

config management loading configurations