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

Bob Majdak:
Extending an Iterator to use an Iterator to make your code a little cleaner
March 12, 2013 @ 09:25:04

In this new post to his site Bob Majdak talks about extending iterators to help make it easier to customize it for your needs.

One of the nice things about iterators is the ability to shove them into other iterators, allowing you to wrap their functionality in other functionality to return a more precise result set. Take for example the idea that we want to read a directory to list only the images inside of it. There are two main ways to do this, via readdir functions and via FilesystemIterator objects. Going the FilesystemIterator route, one common way seems to be extend another class called FilterIterator which allows you to customize a filter based on you overwriting a method called accept().

He shows not only overriding the "accept" method, but also the constructor to make using this new iterator a much simpler (and cleaner) call. You can find out more about the FilesystemIterator (and others) over in the Iterators section of the PHP manual.

0 comments voice your opinion now!
extend iterator clean code accept constructor filesystemiterator


Jason Fox:
Use the Accept Header to Set Your Return Data With Zend Framework 2
February 22, 2013 @ 11:42:35

Jason Fox has a recent post to his site about using "Accept" headers in Zend Framework 2 apps to set the format of the return data from a request.

In this article I detail the process by which you can set up your controller actions in Zend Framework 2 to return either the default HTML, or JSON data depending on the "Accept Header" in the request. It incorporates changes related to a security update added since this very helpful article was written, and expands on some of the intricacies of making your web layer objects better "json providers."

His example uses a "ViewJsonStrategy" and the criteria to look for to determine which version to respond with (HTML or JSON) - the Accept header. It uses the JSON encoder/decoder instead of the built-in PHP one to he could use the included "toJson" method to customize the output of the JSON instead of just returning everything.

0 comments voice your opinion now!
accept http header zendframework2 tutorial json


php|architect Blog:
Professional Programming DTAP - Part 1 What is DTAP?
July 06, 2009 @ 20:23:54

Cal Evans has posted the first part of his look at DTAP - development, testing, acceptance and production - and how it applies to PHP development.

There are four primary systems that need to be set up and isolated. And they are described by the acronym DTAP-Development, Testing, Acceptance, and Production. One thing that has changed recently, though, is that these systems no longer have to mean separate hardware.

He gives an overview of each, setting out definitions to be used for the rest of the series with the next part discussing some of the "smaller moving pieces" of the process.

0 comments voice your opinion now!
production accept test develop dtap



Community Events





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


deployment community bugfix opinion framework introduction update version interview series release language library package api zendserver podcast unittest symfony laravel

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