[英]Symfony2: KnpSnappy Bundle - Trying to access cache file as http://
我不断得到错误:
错误:无法加载页面http:///home/livesmartbureau/var/cache/prod/snappy/knp_snappy58e64e79602c84.27350345.html (有时它只会忽略此错误并使用--load-error-handling ignore)退出代码1由于网络错误:HostNotFoundError
它试图通过预先挂起的http://访问其OWN缓存文件(它写的)
我的config.yml如下:
knp_snappy:
pdf:
enabled: true
binary: /usr/local/bin/wkhtmltopdf
options: []
image:
enabled: true
binary: /usr/local/bin/wkhtmltopdf
options: []
temporary_folder: "%kernel.cache_dir%/snappy"
控制器代码:
$content = $this->render('Trace/traceHistoryDetails.html.twig',array(
'history' => $_SESSION['trace_history'],
'view' => 'PDF'
))->getContent();
$pdfGenerator = $this->get('knp_snappy.pdf');
$pdfGenerator->getInternalGenerator()->setTimeout(120);
return new Response($pdfGenerator->getOutputFromHtml($content), 200, array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="search_history.pdf"'
));
我试过带引号的临时文件夹,没有引号。 我尝试了各种不同的临时文件夹。 “snappy”文件夹正在/ home / livesmartbureau / var / cache / prod中创建。
我到处寻找解决方案,但我无法找到。 这个问题偶然“间歇地”发生并且不是所有时间都没有我可以检测到它何时工作以及何时不能检测到的模式(内容大小似乎不重要,因为它有时会发生在1页PDF和其他倍10页PDF适用于相同的枝条模板,只需更多数据)。
你可以试试renderView
而不是render
吗? 所有文档都显示了这就是我使用的内容:
$content = $this->renderView('Trace/traceHistoryDetails.html.twig',array(
'history' => $_SESSION['trace_history'],
'view' => 'PDF'
))->getContent();
我不确定它是否会有所作为,但请试一试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.