koshatul/config

Koshatul Config Class

v1.2.1 2016-09-23 02:48 UTC

This package is not auto-updated.

Last update: 2024-11-05 04:27:24 UTC


README

A Configuration class for PHP for keeping configuration items separate from repositories or incorporating config into repositories.

Build Status Latest Stable Version Total Downloads

Installation

Use Composer to install the package:

Add the following to your composer.json and run composer update.

"require": {
    "koshatul/config": "~1.0"
}

Example

Example configuration file (could be in project root (in the repository), above that or in the users home directory)

[testsection]
test="testdatavalue"

[anothersection]
test="differentvalue"

[uritest]
mysqlurl="mysql://username:password@hostname:1234/schema"

Usage

You can use this package to get configuration from a global or specific configuration store.

It will pull values from the specified file first, and fallback to environment variables.

Config::Get('project/apikey')

would look in the file first for

[project]
apikey="value"

and fallback to the environment variable

PROJECT_APIKEY="value"
use Koshatul\Config\Config;

$value = Config::Get('project/apikey');

print_r($value);

$array = array(
	'driver'   => 'pdo_mysql',
	'host'     => Config::GetMySQLURI('project/db', PHP_URL_HOST),
	'dbname'   => Config::GetMySQLURI('project/db', PHP_URL_PATH),
	'user'     => Config::GetMySQLURI('project/db', PHP_URL_USER),
	'password' => Config::GetMySQLURI('project/db', PHP_URL_PASS),
	'port'     => $port,
);

print_r($array);