Cache (Twig) is not regenerated in dev mode
Hi, I use the FrankenPHP demo with the worker mode. If we modify a Twig template (with the dev env), docker has to be restarted, so the changes are taken in account. Is it a limitation of the worker mode?
And even if we clear the cache manually, we still have to restart FrankenPHP so see the new changes.
Yes it's intended. Once the file is loaded in memory by PHP (in this case the PHP file corresponding to the Twig template), it will never be parsed and executed again: it stays in memory.
A solution to use the worker mode in dev would be to add a watcher option that will restart the worker if one of the watched files change. To do so, we could use fsnotify: https://github.com/fsnotify/fsnotify
As a workaround @COil, you could try doing something like this in dev mode: https://github.com/dunglas/frankenphp/issues/37#issue-1413245382
The problem is that even FrankenPHP is restarted, the Symfony cache still has to be regenerated. That's what I tried to fix with https://github.com/strangebuzz/cache-watcher. I have to modify it to use https://github.com/fsnotify/fsnotify BTW. Ideally, both should be done.
IIRC, Twig allows you to disable caches too? I can't remember if Symphony exposes this option easily, as it is quite a bit lower level and usually not desired, but that may possibly be a simpler solution in this case.
I took Twig as an example, but it must be the same with the different cache types. Env vars, yaml, translation, entities... Check out https://github.com/strangebuzz/cache-watcher/blob/b5b16d039f7cc59e79ccbad949f2c72a4465e92c/symfony/files.go#L49 (Symfony)
👍, I think what @dunglas suggested would be the simplest long-term solution; I was just trying to help you discover a workaround without a bunch of code churn.
Closing this for now as it's an expected behaviour.