Description
It's currently very confusing and leads to frustration when certain features do not work depending on what context you are in.
For example, when you're in an application/userland, you can use when@<env> in any yaml configuration file to only load said configuration when running in that environment. But when you try and to that from a bundle, it doesn't work and you have to use packages/<env>/<config>.yaml
Given a bundle with a build method as such:
class MyBundle extends AbstractBundle
{
public function build(ContainerBuilder $container): void
{
/** @var string $environment */
$environment = $container->getParameter('kernel.environment');
$configDir = $this->getConfigDir();
$locator = new FileLocator($configDir);
$resolver = new LoaderResolver([
new YamlFileLoader($container, $locator),
new GlobFileLoader($container, $locator),
new DirectoryLoader($container, $locator),
new ClosureLoader($container),
]);
$configLoader = new DelegatingLoader($resolver);
$configLoader->load("$configDir/{packages}/*.{yaml,yml,php}", 'glob');
$configLoader->load("$configDir/{packages}/$environment/*.{yaml,yml,php}", 'glob');
}
protected function getConfigDir(): string
{
return $this->getPath() . '/config';
}
}
You'd expect when@prod in the files found by this bundle to be respected, but in actuality, they're just silently ignored.
Example
Just being able to use the same yaml configuration including when@ keys when loading a config file from a bundle.
framework:
cache:
pools:
cache.app:
adapter: cache.adapter.system
when@prod:
cache:
framework:
pools:
cache.app:
adapters:
- cache.adapter.apcu
- cache.adapter.valkey
default_lifetime: 86400
Description
It's currently very confusing and leads to frustration when certain features do not work depending on what context you are in.
For example, when you're in an application/userland, you can use
when@<env>in any yaml configuration file to only load said configuration when running in that environment. But when you try and to that from a bundle, it doesn't work and you have to usepackages/<env>/<config>.yamlGiven a bundle with a build method as such:
You'd expect
when@prodin the files found by this bundle to be respected, but in actuality, they're just silently ignored.Example
Just being able to use the same yaml configuration including when@ keys when loading a config file from a bundle.