2017 © Pedro Peláez
 

library configure

A configuration repository for PHP.

image

petersuhm/configure

A configuration repository for PHP.

  • Wednesday, March 26, 2014
  • by petersuhm
  • Repository
  • 1 Watchers
  • 3 Stars
  • 16 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Configure

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

A configuration repository for PHP projects., (*2)

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., (*3)

Install

You can install Configure via Composer:, (*4)

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

Basic usage

Using Configure is as simple as instantiating the ConfigurationRepository class and start adding settings to it:, (*5)

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

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

Now you can start querying the repository:, (*6)

$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:, (*7)


$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

As of now, Configure supports YAML and PHP files., (*8)

# config.yml
localization:
    lang: da
    country: dk
app_name: Configure
# config.php
<?php

return array(

    'localization' => array(
        'lang' => 'da',
        'country' => 'dk'
    ),

    'app_name' => 'Configure'
);

In order to load the files, you need to create an instance of the relevant file loader class and provide it to the load() method on the repository:, (*9)

$loader = new \Petersuhm\Configure\Loader\YamlFileLoader('config.yml');
// or
$loader = new \Petersuhm\Configure\Loader\ArrayFileLoader('config.php');

$di->settings->load($loader);

$di->settings->get('localization.lang');
$di->settings->get('app_name');

Testing

Configure is fully covered by unit tests. All code is written using a behavior driven approach with phpspec., (*10)

$ vendor/bin/phpspec run

Contributing

Please see CONTRIBUTING for details., (*11)

Credits

License

The MIT License (MIT). Please see License File for more information., (*12)

The Versions

26/03 2014

dev-master

9999999-dev https://github.com/petersuhm/configure

A configuration repository for PHP.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration

26/03 2014

dev-develop

dev-develop https://github.com/petersuhm/configure

A configuration repository for PHP.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration

25/03 2014

v1.0.1

1.0.1.0 https://github.com/petersuhm/configure

A configuration repository for PHP.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration

24/03 2014

v1.0.0

1.0.0.0 https://github.com/petersuhm/configure

A configuration repository for PHP.

  Sources   Download

MIT

The Development Requires

configuration