Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在模块化PHP模板系统中使用Varnish ESI_Php_Templates_Varnish_Esi - Fatal编程技术网

如何在模块化PHP模板系统中使用Varnish ESI

如何在模块化PHP模板系统中使用Varnish ESI,php,templates,varnish,esi,Php,Templates,Varnish,Esi,我希望将varnish应用到一个数据密集/以用户为中心的网站中。如何使用使用php包含html模板的系统设置ESI 我目前使用一个定制php模板系统(类似于MVC设计模式),其工作原理如下: 生成页面请求->php计算逻辑->php包含html模板页面并填写变量->页面输出 我只见过esi标记主要用于html页面,包括php代码片段 如下面的代码所示: <HTML> <BODY> The time is: <esi:include src="/php-include

我希望将varnish应用到一个数据密集/以用户为中心的网站中。如何使用使用php包含html模板的系统设置ESI

我目前使用一个定制php模板系统(类似于MVC设计模式),其工作原理如下:

生成页面请求->php计算逻辑->php包含html模板页面并填写变量->页面输出

我只见过esi标记主要用于html页面,包括php代码片段

如下面的代码所示:

<HTML>
<BODY>
The time is: <esi:include src="/php-includes/date.php"/>
at this very moment.
</BODY>
</HTML>

时间是:
此时此刻。
但是,是否可以反过来做呢?e、 g.php页面中的esi标记是否包含html片段

与此类似:

<?php
//logic here
$content = "this will be displayed on the content page"

include("templates/header.html.php"); //esi would go here since page is static content
include("templates/content.html.php"); //no esi here, since page is dynamic content
include("templates/footer.html.php"); //esi would go here since page is static content
?>

您只需为特定的MVC实现创建一种“ESI”渲染器,如
/ESI.php?template=foo
中所示,然后在类似以下内容中:

... whatever you need to boostrap your app in order to render a template ....
include("templates/$template.html.php");
.... exit so no header/fooder stuff is rendered, only template HTML of interest
当然不是那么简单,但简而言之,是一件类似的事情


然后,我会在每个模板文件上放置一些逻辑,以发出HTML(如果由
esi.php
呈现,或者如果esi“feature”处于禁用状态)或
您只需为特定MVC实现创建一种“esi”呈现器,如
/esi.php?template=foo
中所示,然后在类似以下内容的内部:

... whatever you need to boostrap your app in order to render a template ....
include("templates/$template.html.php");
.... exit so no header/fooder stuff is rendered, only template HTML of interest
当然不是那么简单,但简而言之,是一件类似的事情

然后,我会在每个模板文件上放置一些逻辑,以发出HTML(如果由
esi.php
呈现,或者如果esi“feature”处于禁用状态)或