News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

MaltBlue.com:
Basic CSV Output in Zend Framework 2
July 18, 2013 @ 09:20:42

Matthew Setter has a new post on the MaltBlue site about creating CVS output from a Zend Framework 2 based application. Instead of writing to a CSV file on the local file system, he opts to push the information out to the user directly in the browser.

Today's tutorial is a simple one. We're going to look at a simple way of rendering CSV output in Zend Framework 2 using a combination of a View Template and Controller Action. We're going to see just how easy it is to generate content and send it to the browser, instead of rendering a standard .pthml template.

He includes the module configuration that sets up the location of the CSV template file and defines the "download/download-csv" header. The view template is pretty simple - just a loop of the results that calls fputcsv to push the data info a file handle. The code for the controller is also included, showing how to create a view model to push the data out.

0 comments voice your opinion now!
cvs output zendframework2 tutorial viewmodel

Link: http://www.maltblue.com/tutorial/simple-csv-output-in-zend-framework-2

Raymond Kolbe's Blog:
DOMPDF in ZF2
July 06, 2012 @ 10:08:27

Raymond Kolbe has a recent post to his blog about using the DOMPDF library to generate PDFs in a Zend Framework 2 application.

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 DOMPDF (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.

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 DOMPDFModule (a ViewModel). You can find out more about this module in it's README on github.

0 comments voice your opinion now!
dompdf zendframework2 tutorial viewmodel


Rob Allen's Blog:
Access view variables in another view model
April 03, 2012 @ 12:53:37

In this new post to his blog Rob Allen shows you how to access the view variables from another ViewModel.

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.

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.

0 comments voice your opinion now!
view model variables other scope child viewmodel zendframework2


Rob Allen's Blog:
Returning JSON from a ZF2 controller action
March 29, 2012 @ 08:55:39

In a new post to his blog Rob Allen shows how you can return JSON data directly back from a controller in a Zend Framework 2 application.

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.

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).

0 comments voice your opinion now!
json controller return data jsonmodel viewmodel zendframework2


Ibuildings techPortal:
Create MVC Meet the ViewModel Pattern
November 02, 2010 @ 10:19:18

On the Ibuildings techPortal, there's a new tutorial posted from Barney Hanlon 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.

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.

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).

0 comments voice your opinion now!
viewmodel framework view presentation model inject



Community Events





Don't see your event here?
Let us know!


release api introduction developer wordpress threedevsandamaybe configure series symfony language laravel install podcast list interview library unittest community application code

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework