Closed
Description
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 which initializeContainer()
is overridden to always use a fresh config), available as a test class like KernelTestCase
.
WDYT?
Activity
[-][Cache] Add NullCacheWarmer[/-][+][Cache] Disable cache[/+]jameshalsall commentedon Sep 3, 2016
I'm unsure what you are asking? You can create your own
NoCacheKernel
inapp/
(in the symfony-standard edition) and override theinitializeContainer()
method like you said.theofidry commentedon Sep 3, 2016
@jameshalsall I'm basically asking to have something like that in Symfony core as we have something like
KernelTestCase
.That said I tried to do that:
(it's the same as the parent with
fresh
always at true), yet this does not work: from one test to another with a different configuration, I get the wrong config at the end. The config is correctly loaded (the right file), but somehow I get the previous config in the end. I can see that because one of my bundle injects the configuration parameters to the parameter bag and I'm getting the wrong values.The whole
AppKernel
can be found here and the bundle I'm referring to is here.jameshalsall commentedon Sep 3, 2016
I don't understand what you mean by "the config is loaded correctly, but somehow I get the previous config at the end"?
nicolas-grekas commentedon Sep 3, 2016
Just for correct triage, this is related to FrameworkBundle, not to the Cache component, isn't it?
theofidry commentedon Sep 3, 2016
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
NullCacheWarmer
...[-][Cache] Disable cache[/-][+]Disable configuration cache[/+]jameshalsall commentedon Sep 5, 2016
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.
theofidry commentedon Sep 5, 2016
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.
ibasaw commentedon Dec 13, 2017
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 ?
ibasaw commentedon Dec 14, 2017
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