<?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>Fri, 24 May 2013 23:30:27 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Rob Allen's Blog: Returning JSON using the Accept header in ZF2]]></title>
      <guid>http://www.phpdeveloper.org/news/17756</guid>
      <link>http://www.phpdeveloper.org/news/17756</link>
      <description><![CDATA[<p>
In a <a href="http://phpdeveloper.org/news/17748">previous post</a> <i>Rob Allen</i> showed how to return JSON data from a controller in a Zend Framework 2 application. In <a href="http://akrabat.com/zend-framework-2/returning-json-using-the-accept-header-in-zf2/">this new post</a> he shows how to use the "Accepts" header from the client to do the same thing.
</p>
<blockquote>
Following yesterday's article on <a href="http://akrabat.com/zend-framework-2/returning-json-from-a-zf2-controller-action/">returning JSON from a ZF2 controller action</a>, <a href="http://twitter.com/lsmith">Lukas</a> suggested that I should also demonstrate how to use the Accept header to get JSON. So this is how you do it!
</blockquote>
<p>
You'll need to <a href="http://akrabat.com/zend-framework-2/returning-json-from-a-zf2-controller-action/">create the JsonStrategy</a> first, then you can return the ViewModel from the controller. If all goes well, you should see the sample HTML page rendered in a browser and JSON output when requested with the right "Accept" header (he uses curl in his example).
</p>]]></description>
      <pubDate>Fri, 30 Mar 2012 08:01:56 -0500</pubDate>
    </item>
  </channel>
</rss>
