2017 © Pedro Peláez
 

library config

Allows easy, interfaceable class configurator with the ability to change the configuration during runtime

image

aloframework/config

Allows easy, interfaceable class configurator with the ability to change the configuration during runtime

  • Monday, November 7, 2016
  • by Alorel
  • Repository
  • 1 Watchers
  • 0 Stars
  • 336 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

AloFramework | Config

A component that allows easy object configuration with default and overriding settings, (*1)

Latest release API documentation: https://aloframework.github.io/config/, (*2)

License Latest Stable Version Total Downloads, (*3)

dev-develop Latest release
Dev Build Status Release Build Status
Coverage Status Coverage Status

Installation

Installation is available via Composer:, (*4)

composer require aloframework/config

The abstract class

AloFramework\Config\AbstractConfig is what your own library configurations should extend. It has three main private properties: $defaults holding default configuration, $custom holding custom configuration/overrides and $merged, which holds the actual configuration that will be used. Your overriding config class will populate the default array and accept any custom variables in the constructor, e.g.:, (*5)

use AloFramework\Config\AbstractConfig;

class MyConfig extends AbstractConfig {

    private static $defaultConfig = ['foo'          => 'bar',
                                     'importantVar' => 'andItsValue'];

    function __construct($customConfig = []) {
        parent::__construct(self::$defaultConfig, $customConfig);
    }
}

When reading the configuration, the values are fetched from the $merged array, which is essentially an array_merge($this->defaults, $this->custom). For more information refer to the API documentation above., (*6)

The interface

You can implement the AloFramework\Config\Configurable interface in your configuration-reading class to indicate that its runtime settings can be altered using this package. The trait described below can be used to implement the required methods., (*7)

The trait

If you don't want to write your own methods you can simply include the provided AloFramework\Config\ConfigurableTrait which will implement all the methods required by the interface., (*8)

Updating the configuration

Setting an item

You can add a custom configuration key or default setting override by calling $config->set('myKey', 'myValue'), using __set() like $config->myKey = 'myValue', or simply using it like an array: $config['myKey'] = 'myValue'., (*9)

Removing an item

You can remove custom configuration via $config->remove('myKey'), or by unsetting it like an array value: unset($config['myKey']);, (*10)

Reading the configuration

Specific value

You can retrieve a specific configuration item from the merged array by calling $config->get('myKey'), using __get() like $config->myKey or by using the object like an array: $config['myKey']., (*11)

The merged config

You can retrieve the merged array via $config->getAll(), (*12)

The default config

For this you would use $config->getDefaultConfig(), (*13)

The custom overrides

For this you would use $config->getCustomConfig()., (*14)

The Versions

07/11 2016

dev-master

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

Allows easy, interfaceable class configurator with the ability to change the configuration during runtime

  Sources   Download

Apache-2.0

The Requires

 

php configuration config interface 5.4 aloframework

07/11 2016

dev-develop

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

Allows easy, interfaceable class configurator with the ability to change the configuration during runtime

  Sources   Download

Apache-2.0

The Requires

 

php configuration config interface 5.4 aloframework

07/11 2016

2.0.1

2.0.1.0 https://github.com/aloframework/config

Allows easy, interfaceable class configurator with the ability to change the configuration during runtime

  Sources   Download

Apache-2.0

The Requires

 

php configuration config interface 5.4 aloframework

07/11 2016

2.0

2.0.0.0 https://github.com/aloframework/config

Allows easy, interfaceable class configurator with the ability to change the configuration during runtime

  Sources   Download

Apache-2.0

The Requires

 

php configuration config interface 5.4 aloframework

12/12 2015

1.1

1.1.0.0 https://github.com/aloframework/config

Allows easy, interfaceable class configurator with the ability to change the configuration during runtime

  Sources   Download

GPL-3.0+

The Requires

 

php configuration config interface 5.4 aloframework

14/10 2015

1.0.2

1.0.2.0 https://github.com/aloframework/config

Allows easy, interfaceable class configurator with the ability to change the configuration during runtime

  Sources   Download

GPL-3.0+

The Requires

 

php configuration config interface 5.4 aloframework

12/10 2015

1.0.1

1.0.1.0 https://github.com/aloframework/config

Allows easy, interfaceable class configuration with the ability to change the configuration during runtime

  Sources   Download

GPL-3.0+

The Requires

 

php configuration config interface 5.4 aloframework

05/10 2015

1.0

1.0.0.0 https://github.com/aloframework/config

Allows easy, interfaceable class configuration with the ability to change the configuration during runtime

  Sources   Download

GPL-3.0+

The Requires

 

php configuration config interface 5.4 aloframework