I am trying to create a symfony attachment application. The problem is that the DI container is created during the assembly of the Docker container, which means that I cannot insert runtime parameters into it. So far, I decided to clear the cache at the entry point to the container, but I realized that in some cases it can be quite a difficult operation, so I created a custom compilation function in AppKernel based on the kernel boot function:
public function compile()
{
if ($this->loadClassCache) {
$this->doLoadClassCache($this->loadClassCache[0], $this->loadClassCache[1]);
}
$this->initializeBundles();
$class = $this->getContainerClass();
$cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug);
$container = $this->buildContainer();
$container->compile();
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
}
This function will now be called every time the Docker container is started (before the application starts).
? , ? ( , ).
symfony: https://github.com/symfony/symfony/issues/19525
PR : https://github.com/webplates/symfony-standard/pull/42