PHPackages                             petersuhm/configure - 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. petersuhm/configure

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

petersuhm/configure
===================

A configuration repository for PHP.

v1.0.1(12y ago)330MITPHP

Since Mar 24Pushed 12y ago1 watchersCompare

[ Source](https://github.com/petersuhm/configure)[ Packagist](https://packagist.org/packages/petersuhm/configure)[ Docs](https://github.com/petersuhm/configure)[ RSS](/packages/petersuhm-configure/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

Configure
=========

[](#configure)

[![Build Status](https://camo.githubusercontent.com/53688f19103dcbe4541415a4b5c1617a662036e6a29262b362b0a11f16045859/68747470733a2f2f7472617669732d63692e6f72672f70657465727375686d2f636f6e6669677572652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/petersuhm/configure)[![Total Downloads](https://camo.githubusercontent.com/06677dbe5881c18c82ea46fe666be519498a10188bd912350eb19e0c0c695523/68747470733a2f2f706f7365722e707567782e6f72672f70657465727375686d2f636f6e6669677572652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/petersuhm/configure)[![Latest Stable Version](https://camo.githubusercontent.com/df5d7f8f8368f633d8b4ff591ff9734a2d46fae34ade8283ddf68843494cc751/68747470733a2f2f706f7365722e707567782e6f72672f70657465727375686d2f636f6e6669677572652f762f737461626c652e706e67)](https://packagist.org/packages/petersuhm/configure)

*A configuration repository for PHP projects.*

Configure is a configuration repository for PHP projects. If your app depends on some sort of configuration settings, you can use Configure to handle them. It has a simple API and supports for different kinds of configuration file [formats](#using-configuration-files).

Install
-------

[](#install)

You can install Configure via Composer:

```
{
    "require": {
        "petersuhm/configure": "dev-master"
    }
}
```

Basic usage
-----------

[](#basic-usage)

Using Configure is as simple as instantiating the `ConfigurationRepository`class and start adding settings to it:

```
$di->settings = new \Petersuhm\Configure\ConfigurationRepository();

$di->settings->set('template_path', '../templates');
```

Now you can start querying the repository:

```
$di->settings->get('template_path');

// You can also provide a default value to be returned
$di->settings->get('not_set', 'default_value');
```

Configure also has supports for arrays:

```
$di->settings->set([
    'lang' => 'da',
    'country' => 'dk'
]);

// Multi dimensional arrays will be flattened using dot notation
$di->settings->set([
    'localization' => [
        'lang' => 'da',
        'country' => 'dk'
    ]
]);
$di->settings->get('localization.lang');
$di->settings->get('localization.country');
```

Using configuration files
-------------------------

[](#using-configuration-files)

As of now, Configure supports [YAML](http://www.yaml.org/) and PHP files.

```
# config.yml
localization:
    lang: da
    country: dk
app_name: Configure
```

```
# config.php
