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: en
And parameters.yml
can configure extensions:
# app/config/parameters.yml
framework:
secret: oihpoaehp97235rgio
However, I don't recommend to do this, as all files have different meanings:
config.yml
/config_*.yml
define extension configurationparameters.yml
defines environment parameters, that shouldn't be commitedservices.yml
configures global service container parameters and servicessecurity.yml
defines security configuration (which is just an extension), as it can get quite complictated