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

merging configs #51

Open
glensc opened this issue Feb 17, 2016 · 3 comments
Open

merging configs #51

glensc opened this issue Feb 17, 2016 · 3 comments

Comments

@glensc
Copy link
Contributor

glensc commented Feb 17, 2016

hi

i would like to have "dist" config and "local" configs, so most of the things, like declaring formatters, processors, handlers are done in "dist" file and loggers from "local" file

from current code reading i see Cascade::fileConfig would just overwrite self::$config, so no merging there.

@rantonmattei
Copy link
Contributor

What would you want? Being able to call it twice and have the 2 configs merged?

I would probably add a method to load the config array into the Config object without configuring it (i.e. parse and interpret).

    /**
     * Load configuration options from a file or a string without configuring Cascade
     *
     * @param string $resource path to config file or string or array
     */
    public static function loadConfig($resource)
    {
        self::$config = new Config($resource, new ConfigLoader());
        self::$config->load();
    }

And then call it one or more times:

Cascade::loadConfig('./my/first_config.yml');
Cascade::loadConfig('./my/second_config.yml');

Cascade::getConfig()->configure();

You would also need to add an array_merge the in the load method of the Config class.

@rantonmattei
Copy link
Contributor

The alternative would be to do the merging offline before you even use Cascade. You read your config files merge them into an array using array_merge and then call Cascade::fileConfig($yourMergedArray)

@glensc
Copy link
Contributor Author

glensc commented Feb 17, 2016

yup. i already went with the array way. but for future would be good if cascade supported this out of the box. symfony does so ;)

keywan-ghadami-oxid added a commit to TeamPull/monolog-configuration that referenced this issue Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants