It all starts with the booting of the kernel, which builds the container. As
you see, $this->registerContainerConfiguration() is called (an abstract method)
class Kernel
{
protected function buildContainer()
{
$container = $this->getContainerBuilder();
$container->addObjectResource($this);
$this->prepareContainer($container);
if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) {
$container->merge($cont);
}
}
}https://github.com/symfony/HttpKernel/blob/master/Kernel.php#L577-601
This method is set in the AppKernel:
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}https://github.com/symfony/symfony-standard/blob/2.7/app/AppKernel.php#L32-35
Assume it's the prod environment, $this->getRootDir()/config/config_prod.yml is loaded:
# app/config/config_prod.yml
imports:
- { resource: config.yml }
# ...As you can see, it imports config.yml:
# app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# ...As you see here, config.yml imports the parameters.yml.
All these files are loaded by the same loaders
and there is no difference in the handling of these files. So config.yml can define parameters:
# app/config/config.yml
# ...
parameters:
locale: enAnd parameters.yml can configure extensions:
# app/config/parameters.yml
framework:
secret: oihpoaehp97235rgioHowever, I don't recommend to do this, as all files have different meanings:
config.yml/config_*.ymldefine extension configurationparameters.ymldefines environment parameters, that shouldn't be commitedservices.ymlconfigures global service container parameters and servicessecurity.ymldefines security configuration (which is just an extension), as it can get quite complictated