PHPackages                             mattferris/configuration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mattferris/configuration

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mattferris/configuration
========================

A configuration manager

1.0(2y ago)01331BSD-2-ClausePHP

Since Jan 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/mattferris/configuration)[ Packagist](https://packagist.org/packages/mattferris/configuration)[ RSS](/packages/mattferris-configuration/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (6)Used By (1)

Configuration
=============

[](#configuration)

[![Build Status](https://camo.githubusercontent.com/2fa762cc5c80c6133be1051f1a9cfbb7f8ccc5b44106345e7caeeae31897e9b6/68747470733a2f2f7472617669732d63692e6f72672f6d6174746665727269732f636f6e66696775726174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mattferris/configuration)

A configuration management library.

```
composer require mattferris/configuration

```

Configuration helps you load and manage runtime configuration. It's flexible enough to let you load any type of configuration resource you want, but not so complex as to be unwieldly for smaller projects.

```
use MattFerris\Configuration\Configuration;
use MattFerris\Configuration\Locators\FileLocator;
use MattFerris\Configuration\Loader\PhpLoader;

// setup a file locator with one or more search paths
$locator = new FileLocator(['foo/path', 'bar/path']);

// setup a loader for the type of files you want to  load
$loader = new PhpLoader();

$config = new Configuration($locator, $loader);

// load a config file, the locator will search for the file using the search paths
$config->load('config.php');

// get a configuration value
$config->get('password');

// get a nested configuration value
$config->get('db.host');

// dump the configuration
$values = $config->get();

/*
 * $values contains:
 *
 * [
 *     'password' => 'banana',
 *     'db' => [
 *         'host' => 'localhost'
 *     ]
 * ]
 */
```

In the above example, `config.php` would look like;

```
