2017 © Pedro Peláez
 

library dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

image

dflydev/dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

  • Monday, December 12, 2016
  • by simensen
  • Repository
  • 2 Watchers
  • 96 Stars
  • 1,717,914 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 4 Forks
  • 6 Open issues
  • 5 Versions
  • 16 % Grown

The README.md

Dot Access Configuration

Given a deep data structure representing a configuration, access configuration by dot notation., (*1)

This library combines dflydev/dot-access-data and dflydev/placeholder-resolver to provide a complete configuration solution., (*2)

Requirements

Usage

Generally one will use an implementation of ConfigurationBuilderInterface to build ConfigurationInterface instances. For example, to build a Configuration out of a YAML file, one would use the YamlFileConfigurationBuilder:, (*3)

use Dflydev\DotAccessConfiguration\YamlFileConfigurationBuilder;

$configurationBuilder = new YamlFileConfigurationBuilder('config/config.yml');
$configuration = $configurationBuilder->build();

Once created, the Configuration instance behaves similarly to a Data instance from dflydev/dot-access-data., (*4)

$configuration->set('a.b.c', 'ABC');
$configuration->get('a.b.c');
$configuration->set('a.b.e', array('A', 'B', 'C'));
$configuration->append('a.b.e', 'D');

Custom Configurations

Configuration Builders use Configuration Factories and Placeholder Resolver Factories behind the scenes in order to build a working configuration., (*5)

Under normal circumstances one should not need to do anything with the Placeholder Resolver Factory. However, one may wish to extend the default Configuration class or use an entirely different implementation altogether., (*6)

In order to build instances of custom ConfigurationInterface implementations with the standard builders, one would need to implement ConfigurationFactoryInterface and inject it into any ConfigurationBuilderInterface., (*7)

If a Configuration is declared as follows:, (*8)

namespace MyProject;

use Dflydev\DotAccessConfiguration\Configuration;

class MyConf extends Configuration
{
    public function someSpecialMethod()
    {
        // Whatever you want here.
    }
}

Create the following factory:, (*9)

namespace MyProject;

use Dflydev\DotAccessConfiguration\ConfigurationFactoryInterface;

class MyConfFactory implements ConfigurationFactoryInterface
{
    /**
     * {@inheritdocs}
     */
    public function create()
    {
        return new MyConf;
    }
}

To use the factory with any builder, inject it as follows:, (*10)

use Dflydev\DotAccessConfiguration\YamlFileConfigurationBuilder;
use MyProject\MyConfFactory;

$configurationBuilder = new YamlFileConfigurationBuilder('config/config.yml');

// Inject your custom Configuration Factory
$configurationBuilder->setConfigurationFactory(new MyConfFactory);

// Will now build instances of MyConfFactory instead of
// the standard Configuration implementation.
$configuration = $configurationBuilder->build();

License

This library is licensed under the New BSD License - see the LICENSE file for details., (*11)

Community

If you have questions or want to help out, join us in the #dflydev channel on irc.freenode.net., (*12)

The Versions

12/12 2016

dev-master

9999999-dev https://github.com/dflydev/dflydev-dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration config

12/12 2016

v1.0.2

1.0.2.0 https://github.com/dflydev/dflydev-dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration config

14/11 2014

v1.0.1

1.0.1.0 https://github.com/dflydev/dflydev-dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration config

22/10 2012

v1.0.0

1.0.0.0 https://github.com/dflydev/dflydev-dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration config

17/07 2012

v1.0.0-BETA1

1.0.0.0-beta1 https://github.com/dflydev/dflydev-dot-access-configuration

Given a deep data structure representing a configuration, access configuration by dot notation.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration config