-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Disable configuration cache #19834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm unsure what you are asking? You can create your own |
@jameshalsall I'm basically asking to have something like that in Symfony core as we have something like That said I tried to do that: protected function initializeContainer()
{
$class = $this->getContainerClass();
$cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug);
$container = $this->buildContainer();
$container->compile();
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
require_once $cache->getPath();
$this->container = new $class();
$this->container->set('kernel', $this);
} (it's the same as the parent with The whole |
I don't understand what you mean by "the config is loaded correctly, but somehow I get the previous config at the end"? |
Just for correct triage, this is related to FrameworkBundle, not to the Cache component, isn't it? |
I have one config file with "nothing" it it, i.e. with the default values for my bundle configuration (they are all optional). And I have another config file with different values from the default one. In my extension, I'm injecting those configuration values into the container. In my test cases, sometimes I'm loading a kernel loaded with the regular config file, another time with the other. Each time I shutdown and boot the kernel properly, each test individually pass. Yet if I run the whole testsuite my test fails because I get the wrong parameters. @nicolas-grekas yes indeed sorry about that, I first though it was related to the cache warmer and I wanted to register a |
I think that answers your question, you need to boot a new Kernel when new configuration should be loaded. Once the config is loaded when the Kernel is booted it will not try to load configuration again as it is stored in memory. |
Indeed, and so the easiest way to solve that is to generate a Kernel with a different environment each time. Thanks for the tip @jameshalsall :) Maybe this should be documented somewhere, but not really sure were it would be the appropriate place for that. |
need same thing...but don't know how to do it. i try to do a multi domain website on same code, all change with the domain url. i got a parameter.php file, inside this file, i define some parameters by domain. I got a problem with the cache, the configuration is only the first time run, because it read again in the cache. How to disable cache for parameters.php ? @theofidry : how did you solved your problem ? |
found it ! i use an array and pass it to the kernel, in the kernel i set up different cache dir depends on the array configuration |
As of now, a cache warmer is always used. Unlike some other components like the serializer, the cache cannot be completely disabled via the configuration.
In my case for example, I'm loading a kernel with different configuration files, i.e. I must make sure the configuration is not cached between each loading. As I hardly see anyone who would want to disable cache to the point of not caching the configuration, rather than adding a config parameter I would rather be up for adding a
NoCacheKernel
class (in whichinitializeContainer()
is overridden to always use a fresh config), available as a test class likeKernelTestCase
.WDYT?
The text was updated successfully, but these errors were encountered: