Zend_Controller_Response should be aggregate all responses emitted by the controller chain. This has the benefit of ensuring that headers are always emitted prior to content, as well as allowing the developer to write unit tests against their front controller. A simple way to do so would be to use output buffering.
<p>I can't see a downside and is a pretty low impact change for those who don't want to use it.</p>
<p>We're going to need a master list of all the parameters that the "C" does something with soon though, as I'm losing track of the options available!</p>
<p>The ability to capture the "echo'd" output of all executed actions would be much more interesting to me, if the output was saved to a named body "segment" in the response object.</p>
<p>Explains the idea of named segments for response objects:
<a class="external-link" href="http://framework.zend.com/issues/browse/ZF-1024">http://framework.zend.com/issues/browse/ZF-1024</a></p>
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
if (!empty($content))
<p>Why? All of my code uses views and explicitly renders into "segments". Anything "echo'd" is a mistake that I would like to have logged using the new Zend_Log instead of shown on a production website <ac:emoticon ac:name="smile" /></p>
<p>I can see the value of this enhancement and how it is a building-block toward hierarchies of controllers, etc. It also solves cases of the 'headers already sent' issue.</p>
<p>My only concern is that this will be a significant backward-compatibility break.<br />
If a developer upgrades ZF but neither sets outputBuffering(false) or echoes the response body, will <br />
will find their MVC app outputs nothing, right?</p>
<p>By default, Zend_Controller_Front::dispatch() calls $response->sendOutput(), which sends the aggregated body content and headers. So, in the end, the only difference is <strong>when</strong> content is sent.</p>
<ac:macro ac:name="note"><ac:parameter ac:name="title">"Official Zend Comment"</ac:parameter><ac:rich-text-body>
<p>Okay, the benefits to testability have persuaded me that this change is worth the BC breakage. This provides value matching that of the instantiable Request object introduced in ZF 0.2.</p>
<p>This enhancement is approved for development in the incubator. Optionally you may develop in the core directory, in a svn branch off of the trunk.</p>
<p>I request that you write a manual section addressing testing methodology for MVC applications, and how to use the Request and Response objects to write unit tests for web applications.</p></ac:rich-text-body></ac:macro>
7 Comments
comments.show.hideMar 07, 2007
Matthew Ratzloff
<p>I'm highly in favor of this!</p>
Mar 08, 2007
Rob Allen
<p>I can't see a downside and is a pretty low impact change for those who don't want to use it.</p>
<p>We're going to need a master list of all the parameters that the "C" does something with soon though, as I'm losing track of the options available!</p>
<p>Regards,</p>
<p>Rob...</p>
Mar 08, 2007
Gavin
<p>The ability to capture the "echo'd" output of all executed actions would be much more interesting to me, if the output was saved to a named body "segment" in the response object.</p>
<p>Explains the idea of named segments for response objects:
<a class="external-link" href="http://framework.zend.com/issues/browse/ZF-1024">http://framework.zend.com/issues/browse/ZF-1024</a></p>
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
if (!empty($content))
]]></ac:plain-text-body></ac:macro>
<p>Why? All of my code uses views and explicitly renders into "segments". Anything "echo'd" is a mistake that I would like to have logged using the new Zend_Log instead of shown on a production website <ac:emoticon ac:name="smile" /></p>
Mar 09, 2007
Bill Karwin
<p>I can see the value of this enhancement and how it is a building-block toward hierarchies of controllers, etc. It also solves cases of the 'headers already sent' issue.</p>
<p>My only concern is that this will be a significant backward-compatibility break.<br />
If a developer upgrades ZF but neither sets outputBuffering(false) or echoes the response body, will <br />
will find their MVC app outputs nothing, right?</p>
Mar 09, 2007
Matthew Weier O'Phinney
<p>By default, Zend_Controller_Front::dispatch() calls $response->sendOutput(), which sends the aggregated body content and headers. So, in the end, the only difference is <strong>when</strong> content is sent.</p>
Mar 09, 2007
Bill Karwin
<ac:macro ac:name="note"><ac:parameter ac:name="title">"Official Zend Comment"</ac:parameter><ac:rich-text-body>
<p>Okay, the benefits to testability have persuaded me that this change is worth the BC breakage. This provides value matching that of the instantiable Request object introduced in ZF 0.2.</p>
<p>This enhancement is approved for development in the incubator. Optionally you may develop in the core directory, in a svn branch off of the trunk.</p>
<p>I request that you write a manual section addressing testing methodology for MVC applications, and how to use the Request and Response objects to write unit tests for web applications.</p></ac:rich-text-body></ac:macro>
Mar 09, 2007
Matthew Weier O'Phinney
<p>I will address unit testing of MVC applications in the documentation as I revamp and reorganize the docs for 0.9.</p>