Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include/Import config #33

Open
nickl- opened this issue Feb 8, 2013 · 4 comments
Open

Include/Import config #33

nickl- opened this issue Feb 8, 2013 · 4 comments
Milestone

Comments

@nickl-
Copy link
Member

nickl- commented Feb 8, 2013

What about include config considered a dependency which may have values referenced and thus should be processed first. The result will be a combination of settings perhaps in the form:

$result = $config + $config_include_last + $config_include_n_desc + $config_include; 

Allowing each to overwrite settings from the previous.

Now we just have to decide what an import/include looks like.
Perhaps also a header comment in order to use the same key

; import defailt.ini

or we could use an array

import = [default.ini, production.ini, app.ini]

I would rather prefer a list underneath each other though

import = $import:path/to/default.ini
matters = $import:path/to/matters.ini
not = $import:path/to/not.ini

Hmmm little weird... thoughts?

@alganet
Copy link
Member

alganet commented Feb 8, 2013

I've been using a pattern for a quite long time:

<?php
$configLoader = new Container('loader.ini');
$config = $configLoader->config;
[config Respect\Config\Container]
loadFile[] = [default.ini]
loadFile[] = [production.ini]
loadFile[] = [app.ini]

Works pretty well! Perhaps we could institutionalize this pattern. Some kind of:

[this]
loadFile[] = [app.ini]

[conn PDO]
etc = ...

@nickl-
Copy link
Member Author

nickl- commented Feb 10, 2013

Yes of course an array! Why didn't I think of that.

@alganet Have you given overwriting preference any thought? I guess we have two options top-down or bottom-up, unless there are something like arrays which I'm not seeing. =)

Dependencies are a non issue as all the values will be loaded before they ever become required, iow the order does not impact dependency unlike overwriting which will require a definitive preference where conflicting properties are found.

@alganet
Copy link
Member

alganet commented Feb 12, 2013

I'm pretty sure the Container only works from top to bottom. It can handle some missing variables in the way, but I didn't tested with large links between objects missing (which is similar to reading from bottom to top).

Config is pretty fragile. It's magic comes from two limitations: it follows the INI data structure which has limited deepness and it depends on the order of declaration. This limitations also work as reassurance. We can infer a lot more from a limited container and provide runtime flexibility instead of static flexibility. That's why it's code is so hard to change and at the same time so powerful.

@augustohp
Copy link
Member

😊 Just remembered what the issue #23 with "Better entropy solver" had to do about: When we load multiple files, we need to load them in the correct order or declare them in the right order. The issue was to solve that kind of problem, seeking for dependencies and the container (ini) whom had more entropy (dependencies) would be loaded later. Does that ring a bell to you @alganet ?

@augustohp augustohp added this to the 2.1 milestone Dec 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants