1 Dot Access Configuration
2 ========================
4 Given a deep data structure representing a configuration, access
5 configuration by dot notation.
7 This library combines [dflydev/dot-access-data](https://github.com/dflydev/dflydev-dot-access-data)
8 and [dflydev/placeholder-resolver](https://github.com/dflydev/dflydev-placeholder-resolver)
9 to provide a complete configuration solution.
16 * [dflydev/dot-access-data](https://github.com/dflydev/dflydev-dot-access-data) (1.*)
17 * [dflydev/placeholder-resolver](https://github.com/dflydev/dflydev-placeholder-resolver) (1.*)
18 * [symfony/yaml](https://github.com/symfony/Yaml) (>2,<2.2) *(suggested)*
24 Generally one will use an implementation of `ConfigurationBuilderInterface`
25 to build `ConfigurationInterface` instances. For example, to build a Configuration
26 out of a YAML file, one would use the `YamlFileConfigurationBuilder`:
28 use Dflydev\DotAccessConfiguration\YamlFileConfigurationBuilder;
30 $configurationBuilder = new YamlFileConfigurationBuilder('config/config.yml');
31 $configuration = $configurationBuilder->build();
34 Once created, the Configuration instance behaves similarly to a Data
35 instance from [dflydev/dot-access-data](https://github.com/dflydev/dflydev-dot-access-data).
37 $configuration->set('a.b.c', 'ABC');
38 $configuration->get('a.b.c');
39 $configuration->set('a.b.e', array('A', 'B', 'C'));
40 $configuration->append('a.b.e', 'D');
46 Configuration Builders use Configuration Factories and Placeholder Resolver
47 Factories behind the scenes in order to build a working configuration.
49 Under normal circumstances one should not need to do anything with the
50 Placeholder Resolver Factory. However, one may wish to extend the
51 default `Configuration` class or use an entirely different implementation
54 In order to build instances of custom `ConfigurationInterface` implementations
55 with the standard builders, one would need to implement
56 `ConfigurationFactoryInterface` and inject it into any
57 `ConfigurationBuilderInterface`.
59 If a Configuration is declared as follows:
63 use Dflydev\DotAccessConfiguration\Configuration;
65 class MyConf extends Configuration
67 public function someSpecialMethod()
69 // Whatever you want here.
73 Create the following factory:
77 use Dflydev\DotAccessConfiguration\ConfigurationFactoryInterface;
79 class MyConfFactory implements ConfigurationFactoryInterface
84 public function create()
90 To use the factory with any builder, inject it as follows:
92 use Dflydev\DotAccessConfiguration\YamlFileConfigurationBuilder;
93 use MyProject\MyConfFactory;
95 $configurationBuilder = new YamlFileConfigurationBuilder('config/config.yml');
97 // Inject your custom Configuration Factory
98 $configurationBuilder->setConfigurationFactory(new MyConfFactory);
100 // Will now build instances of MyConfFactory instead of
101 // the standard Configuration implementation.
102 $configuration = $configurationBuilder->build();
108 This library is licensed under the New BSD License - see the LICENSE file
115 If you have questions or want to help out, join us in the
116 [#dflydev](irc://irc.freenode.net/#dflydev) channel on irc.freenode.net.