如何在 Zend 的 MVC 中对 headers/buffer 进行后处理?
因此,我按照快速入门指南创建了一个 Zend 应用程序(因此它具有布局,并且大量使用 application.ini 配置而不是硬编码选项),并进行了一些更改,但现在我想操作输出给浏览器...我已经用谷歌搜索过,但似乎我不知道如何搜索,或更重要的是搜索什么...我希望能够做一些类似的事情:
<?php
ob_start();
echo 'Hello ';
echo 'World';
echo '!';
$buffer = ob_get_contents();
ob_end_clean();
echo my_own_function($buffer);
?>
并做一些整洁,评论/空间删除等...我的意思是不仅仅是这样,我希望能够即时进行任何后处理。另外我想在发送之前把手放在标题上(我使用的是 php5.3),这可能吗?
我的意思是哪些类/方法输出标头并将文本发送到浏览器以便可以解释它?
提前致谢。
So, I have created a Zend application following the quick start guide (so it has layouts, and heavy usage of application.ini configurations rather that hard-coded options) with a few changes here and there, but now I want to manipulate the output given to the browser... I've googled but it seems that I don't know how to search or more importantly what to search... I want to be able to do something like:
<?php
ob_start();
echo 'Hello ';
echo 'World';
echo '!';
$buffer = ob_get_contents();
ob_end_clean();
echo my_own_function($buffer);
?>
And do some TIDY, comment/space removing, etc... I mean it isn't just that, I want to be able to do any post-processing on-the-fly. Also I wanna get my hands over the headers before are dispatched (I'm using php5.3) it is possible?
I mean which are the classes/methods that output headers and send text to the browser so it can be interpreted?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您可以编写一个 Zend_Controller 插件。
请参阅此处的文档:Zend 控制器插件。
在您的特定情况下,您需要挂钩 dispatchLoopShutdown 方法。
链接页面上描述了如何编写这些插件。
for this purpose you can write a Zend_Controller plugin.
See the documentation here: Zend Controller Plugins.
In your particular situation, you want to hook on the dispatchLoopShutdown method.
How to write these plugins is described on the linked page.