Seems that the twig getTimestamp() function is not fully compatible with PHP 5.5.12 (windows/linux) and throws an exception when the file is not available.
public function getTimestamp($key)
{
return (int) @filemtime($key);
}
We are using Twig 1.22.2 without the rest of symfony. I was checking for the requested key but this file does not exists. Shouldnt twig check if the file exists before doing a filemtime() call? Otherwise the cache never gets populated. We were configuring twig the following:
$this->loader = new \Twig_Loader_Filesystem($options['TEMPLATE_DIR']);
$this->twig = new \Twig_Environment($this->loader, array(
"auto_reload" => true
, "cache" => 'cache/twig'
));
Like this the cache files are never created. We have to disable the caching to make it working.
"cache" => false
For a production environment this is not working
Another Solution was the following:
public function getTimestamp($key)
{
**return false;**
return (int) @filemtime($key);
}
and then reverting back to the original source. Then the cache files were written to the disk and everything worked like a charm.
I guess something changed in php internals and the twig team needs to adapt to that change. By default twig always expects the file to be there which is for every application on the first hit not the case!