Skip to content

Request: Enhancement (group by file name when Multiple File load) #73

@tmgast

Description

@tmgast

Regarding an old issue #18:

It was asked how to handle when multiple config files share a variable name.

If you're loading in multiple config files, wouldn't it make more sense to contain each loaded file as its own array within the config container?

loading files:
- config/environment.php
- config/services.php
- config/database.php

These should be accessible in the following way:

$app->config = new Config(__DIR__ . '/../config');
$app->config->get('environment.name'); // the name variable is returned from the environment config
$app->config->get('database.server'); // the server variable is returned from the database config

Currently, all the config options are mashed together in a single array, which overwrites any duplicates.

Example:
server.php

<?php

return [
    "system" => "debian",
    "apache" => [
        "location" => "/usr/bin/apache"
    ]
];

environments.php

<?php

return [
    "local" => [
        "domain" => "dev"
    ],
    "production" => [
        "domain" => "domain.com"
    ]
];

Outputs:

{
    "local":{
        "domain":"dev"
    },
    "production":{
        "domain":"domain.com"
    },
    "system":"debian",
    "apache":{
        "location":"\/usr\/bin\/apache"
    }
}

However, I would like it to output:

{
    "environments":{
        "local":{
            "domain":"dev"
        },
        "production":{
            "domain":"domain.com"
        },
    },
    "server": {
        "system":"debian",
        "apache":{
            "location":"\/usr\/bin\/apache"
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions