contao / manager-bundle

[READ-ONLY] Contao Manager Bundle
GNU Lesser General Public License v3.0
17 stars 10 forks source link

config.yml is not loaded when env specific config is present #44

Closed fritzmg closed 7 years ago

fritzmg commented 7 years ago

The config file handling of the Contao Managed Edition behaves differently than in the standard symfony application setup. Usually you can have the following files:

app/config/config.yml
app/config/config_prod.yml
app/config/config_dev.yml

The contents of the config.yml are always loaded and then depending on the environment, the config_prod.yml or config_dev.yml is loaded additionally.

This is not the case in the ContaoKernel:

$loader->load(function (ContainerBuilder $container) use ($loader) {
    $environment = $container->getParameter('kernel.environment');

    if (file_exists($this->getRootDir().'/config/config_'.$environment.'.yml')) {
        $loader->load($this->getRootDir().'/config/config_'.$environment.'.yml');
    } elseif (file_exists($this->getRootDir().'/config/config.yml')) {
        $loader->load($this->getRootDir().'/config/config.yml');
    }
});

Here the config.yml only serves as a fallback. So if a config_prod.yml or config_dev.yml is present, only that config file is loaded.

fritzmg commented 7 years ago

The loading could simply be changed to:

$loader->load(function (ContainerBuilder $container) use ($loader) {
    $environment = $container->getParameter('kernel.environment');

    if (file_exists($this->getRootDir().'/config/config.yml')) {
        $loader->load($this->getRootDir().'/config/config.yml');
    }

    if (file_exists($this->getRootDir().'/config/config_'.$environment.'.yml')) {
        $loader->load($this->getRootDir().'/config/config_'.$environment.'.yml');
    }
});
aschempp commented 7 years ago

The application does follow the standard behavior. You have to import the config.yml in your config_prod.yml if you need it. See https://github.com/symfony/symfony-standard/blob/3.3/app/config/config_prod.yml#L2

fritzmg commented 7 years ago

Right, sorry for the confusion :)