 | News Feed |
Sections
|
| feed this: |  |
PHPImact Blog: Refactoring the Front Controller of the Zend Framework
by Chris Cornutt August 20, 2008 @ 14:04:01
The PHP::Impact blog has a new tutorial posted today with a look at a refactoring of the front controller of the Zend Framework to make it a bit more manageable.
One of the most fundamental decision in object design is deciding where to put responsibilities. No one, and I mean no one, gets it right the first time. That's why refactoring is so important. As Kent Beck puts it, refactoring is the process of taking a system and adding to its value, not by changing its behaviour but by giving it more of these qualities that enable us to continue developing at speed.
He follows the "extract" refactoring method that makes things simpler by removing unneeded parts of the code (in favor of an interchangeable external "extract class". He removes seven methods from the class and splits them off into their own. This reduces the controller down to a more manageable size and takes a lot of the complexity out.
voice your opinion now!
tutorial refactor extract class zendframework front controller
Daniel Cousineau's Blog: Quickie Module-specific Error Controllers in Zend Framework (1.5)
by Chris Cornutt August 12, 2008 @ 07:56:17
Daniel Cousineau has posted a "quickie" over on his blog today dealing with error controllers in a Zend Framework application.
In my quest to do some alterations on ZF error handling (in particular, render the view if the action or controller is not found, makes it real easy for my designer to prototype) I had the desire to be able to allow modules to have their own ErrorControllers. Unfortunately, the Zend_Controller_Plugin_ErrorHandler() default does not allow for this and I didn't really want to extend that class (I planned on handling the rendering in the ErrorControllers) so I wrote up a quick plugin.
His plugin (code included in the post) hooks into the routeShutdown part of the routing process and overrides the default error handler for the module to pass the request off to his custom one.
voice your opinion now!
zendframework module controller error handler routeshutdown
Ibuildings Blog: Dependency Injection and Zend Framework Controllers
by Chris Cornutt July 28, 2008 @ 08:47:40
Ian Barber has written up a look at dependency injection as a part of the Zend Framework's controller functionality for the Ibuildings blog.
Among the standard object oriented principles is favouring composition over inheritance, and there are plenty of design patterns that work along this line. However, one of the most useful day-to-day facets of the idea doesn't seem to get a lot of attention from PHP developers, namely dependency injection.
The general idea is, that if your class depends on some other object, that object should be passed in rather than generated internally or retrieved via a global variable or singleton.
He shares few ideas on how you can use this method in the controller of a Zend Framework including the use of the Zend Registry and an Action Helper. Code snips are provided for reach to show you how it'd be done.
voice your opinion now!
dependency injection zendframework application controller
Jonathan Snook's Blog: Multiple Validation Sets in CakePHP 1.2
by Chris Cornutt July 23, 2008 @ 07:51:27
Jonathan Snook has posted two methods for creating multiple validation sets in the latest version of your CakePHP application.
In CakePHP, you define how your data should be validated by setting parameters on the validate property of your model. In version 1.2, there is an on option that can be set on a specific rule that, when set, is either create or update. [...] Despite that, I developed a slightly different approach that allows for different validation sets to be specified and to be cleanly separated from each other.
He overrides the validates() method with his own in a custom model in one of two ways - having the script check for a validation set for the current controller or by specifying it directly with a validationSet property. Code for both methods is included.
voice your opinion now!
cakephp framework validation set detect controller property define tutorial
PHP in Action Blog: Testing a Zend Framework action controller with View Helpers
by Chris Cornutt June 11, 2008 @ 07:56:11
On the PHP in Action blog, there's a new post about a method for testing a controller as a part of a Zend Framework application with its own view helpers.
I came across a Zend Framework (ZF) example I wanted to refactor. You really have to have unit test coverage to refactor effectively, and since there were no tests, I started trying to find out how to test it. There didn't seem to be a wealth of information available on the web, so I've tried to figure it out by myself.
He walks through the testing process he followed - making some new default objects (for SimpleTest) and, using the flash messenger view helper, makes some mock classes to simulate sending the flash messages in an application.
voice your opinion now!
zendframwork simpletest unittest controller view helper
Padraic Brady's Blog: An Example Zend Framework Blog - Part 5 Models w/Zend_Db & an Admin Module
by Chris Cornutt May 01, 2008 @ 10:25:06
Padraic Brady is on part five of his series looking at making a blogging tool with the Zend Framework today. This time he focuses on the database side of things, working with models and making an admin module.
First of all I decided to add an Entries Model and Authors Model to the mix, primarily to get ready for when we can add new entries to our blog. This leads to where we can create new Entries; we add an Administration Module to the application with it's own distinct Layout.
He starts by making the database schema, an entries and authors table, before starting in on the models. They're made based off of the Zend_Db component's structure and they let the application interact with the data in the tables easily. His code for the modules is included as well as the controller and view for the admin module.
voice your opinion now!
zendframework model zendb zendlayout controller administration module
Zend Developer Zone: Front Controller Plugins in Zend Framework
by Chris Cornutt April 15, 2008 @ 07:58:52
On the Zend Developer Zone, there's a new article that examines one of the key components to just about any framework out there - the front controller.
Like Action Helpers, which I've discussed in a previous article, Front Controller Plugins in Zend Framework are often considered an esoteric, advanced subject. They are, however, remarkably simple to implement, and provide an easy way to extend the functionality and behavior of your entire web application.
The article (from Matthew Weir O'Phinney) looks at the hooks defined in the controller, like routeStartup and preDispatch, and how to work with the controller to add in/get plugins from it. He provides a two examples too: Application Initialization Plugin and a Caching Plugin.
voice your opinion now!
zendframework front controller hook route dispatch
|
Community Events
Don't see your event here? Let us know!
|