<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sat, 18 May 2013 13:59:52 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Rob Allen's Blog: Returning JSON from a ZF2 controller action]]></title>
      <guid>http://www.phpdeveloper.org/news/17748</guid>
      <link>http://www.phpdeveloper.org/news/17748</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Rob Allen</i> shows how you can return JSON data <a href="http://akrabat.com/zend-framework-2/returning-json-from-a-zf2-controller-action/">directly back from a controller</a> in a Zend Framework 2 application.
</p>
<blockquote>
The new view layer in Zend Framework 2 can be set up to return JSON rather than rendered HTML relatively easily. [...] Firstly we need to set up the view's JsonStrategy to check to a situation when returning JSON is required and then to render out JSON for us.
</blockquote>
<p>
This "JsonStrategy" does some of the hard work for you - detecting when the client is requesting a JSON response and looking at the data coming into the view to see if it's JSON. He shows how to implement it in a sample module using the "onBootstrap" module and how to force a return of the JsonModel even when JSON isn't requested (useful for a consistent interface).
</p>]]></description>
      <pubDate>Thu, 29 Mar 2012 08:55:39 -0500</pubDate>
    </item>
  </channel>
</rss>
