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
Is there any chance I can avoid using eval
in Twig?
#2428
Comments
eval is only used when you don't use a Cached template, when you use the cache eval is not used. |
@sciamannikoo if you enable the filesystem cache, eval will be used only in case of race condition on the cache access (which can be avoided if you take care of parsing all templates of your project before putting your server under load) |
Would be great if an alternative solution to |
When you enable the filesystem cache and you don't have race conditions during the cache warmup process (i.e. you're not running your cache warming under load, or you're lucky when doing it under load), |
if you disable the filesystem cache, there is no way to avoid the usage of |
Closing as @stof explained how that works really well. |
I've been looking for a way to keep using Twig, while not using
eval
.Unfortunately, not all our clients are willing to keep it enabled.
So, rather than googling and asking everywhere else (which I did anyway), I thought that this is probably the best place.
My objective is to allow Twig to work when extensions such as Suhosin are installed and
eval
is disabled.I've tried to look at the code in
\Twig_Environment::loadTemplate
and I can't quite understand wheneval('?>'.$content)
is called, but it is called several times.Regardless, I wonder if there is any way I can make Twig stop using the
eval
function.The text was updated successfully, but these errors were encountered: