<?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>Sun, 19 May 2013 16:15:14 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Raymond Kolbe's Blog: DOMPDF in ZF2]]></title>
      <guid>http://www.phpdeveloper.org/news/18191</guid>
      <link>http://www.phpdeveloper.org/news/18191</link>
      <description><![CDATA[<p>
<i>Raymond Kolbe</i> has a recent post to his blog about <a href="http://raymondkolbe.com/2012/07/01/dompdf-in-zf2/">using the DOMPDF library</a> to generate PDFs in a Zend Framework 2 application.
</p>
<blockquote>
If you're using Zend Framework 2 (beta 4) and need to easily generate PDFs, and you'd like to generate those PDFs from an HTML template, then boy do I have some good news for you! For those of you who have dealt with generating dynamic PDFs, you know how much of a pain in the ass it can be (e.g. dealing with x, y coordinates, word-wrap (or lack of), etc.). There are a few options out there, some paid, some free, but none of them are as nice as <a href="http://code.google.com/p/dompdf/">DOMPDF</a> (simple API, powerful, and free). The true power behind DOMPDF comes from rendering standard HTML/CSS files instead of having to write ugly and unmanageable code.
</blockquote>
<p>
He includes a simple example showing how to use the library to create a basic PDF document (containing an HTML string) and how to port that same thing over to work in ZF2 via a custom <a href="http://packagist.org/packages/dino/dompdf-module">DOMPDFModule</a> (a ViewModel). You can find out more about this module in it's <a href="https://github.com/raykolbe/DOMPDFModule/blob/master/README.md">README</a> on github.
</p>]]></description>
      <pubDate>Fri, 06 Jul 2012 10:08:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Rob Allen's Blog: Access view variables in another view model]]></title>
      <guid>http://www.phpdeveloper.org/news/17770</guid>
      <link>http://www.phpdeveloper.org/news/17770</link>
      <description><![CDATA[<p>
In <a href="http://akrabat.com/zend-framework-2/access-view-variables-in-another-view-model/">this new post</a> to his blog <i>Rob Allen</i> shows you how to access the view variables from another ViewModel.
</p>
<blockquote>
Unlike Zend Framework 1, the view layer in Zend Framework 2 separates the variables assigned to each view model. This means that when you are in the layout view script, you don't automatically have access to variables that were assigned the the action's view model and vice versa.
</blockquote>
<p>
He includes snippets of code with an example controller and a sample view that fetches a value from a child ViewModel instance. He also shows how to access layout and configuration values in the view.
</p>]]></description>
      <pubDate>Tue, 03 Apr 2012 12:53:37 -0500</pubDate>
    </item>
    <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>
    <item>
      <title><![CDATA[Ibuildings techPortal: Create MVC: Meet the ViewModel Pattern]]></title>
      <guid>http://www.phpdeveloper.org/news/15368</guid>
      <link>http://www.phpdeveloper.org/news/15368</link>
      <description><![CDATA[<p>
On the Ibuildings techPortal, there's <a href="http://techportal.ibuildings.com/2010/11/02/creative-mvc-meet-the-viewmodel-pattern/">a new tutorial posted</a> from <i>Barney Hanlon</i> looking at a new method that developers can use in their applications to give MVC apps a better way to handle their presentation logic - ViewModel.
</p>
<blockquote>
This provides MVC applications a natural location for presentation logic and lazy functionality while maintaining the segregation between the layers of responsibility within the code. It allows designers access to data and methods they need, while hiding aspects that aren't needed at view level. [...] Indeed, pretty much any modern Web framework has an understanding of the important segregation of duties inherent within MVC. It is precisely this segregation that leads to a certain greyness around the all-important View, particularly on sites where multiple content items are displayed in different ways.
</blockquote>
<p>
The tutorial he includes shows how to set up a site with multiple articles per page that can be shown as either headlines or just title text. He talks about three ways to accomplish this - the usual injection of all data into the view and having it handle it there, injecting a model directly and extracting data from it and the ViewModel approach (a combination of the Decorator and Adapter design patterns).
</p>]]></description>
      <pubDate>Tue, 02 Nov 2010 10:19:18 -0500</pubDate>
    </item>
  </channel>
</rss>
