 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPMaster.com: An Introduction to the Front Controller Pattern, Part 2
by Chris Cornutt August 07, 2012 @ 11:06:55
PHPMaster.com has posted the second part of their series introducing you to one of the more popular design patterns in PHP frameworks right now - the Front Controller pattern. Part 1 introduced some of the fundamental concepts and this new article expands on that, getting more into the request and reponse handling process.
One of the best things about front controllers is that you can keep them running as tight structures, just routing and dispatching incoming requests, or you can let your wild side show and implement a full-fledged RESTful controller capable of parsing HTTP verbs, accommodating pre/post dispatch hooks, and the like, all behind a unified API. [I'd like to show] you how easy is to deploy a small, yet extensible, HTTP framework capable of putting to work a front controller along with the ones of a standalone router and a dispatcher. Plus, the whole request/response cycle will be independently handled by a couple of reusable classes, which naturally you'll be able to tweak at will.
He bases his examples off of the EPHPMVC project, showing how to implement a RequestInterface, ResponseInterface and link them together with a RouteInterface and use the DispatcherInterface to handle the requests. The front controller is then created with its run() method and an instance is created in a main PHP file that all requests are routed through.
voice your opinion now!
frontcontroller designpattern introduction response request dispatch route
Matthew Weier O'Phinney: ZF2's New Controllerinit()
by Chris Cornutt July 31, 2012 @ 08:44:36
In his latest post Matthew Weier O'Phinney introduces you to the new init() method in the Zend Framework 2 controllers and how it differs from the one in version 1.
In Zend Framework 1, controller's had an init() method, which was called after the controller was instantiated. The reason for it was to encourage developers not to override the constructor, and thus potentially break some of the functionality (as a number of objects were injected via the constructor). init() was useful for doing additional object initialization. [...] But this feature is missing from ZF2; how can we accomplish this sort of pattern?
In Zend Framework 2, there's no Controller constructor by default anymore, so you have to do things slightly differently. He shows you how to use the event manager to simulate the same thing, attaching an event to the "dispatch" of the controller to do the work. He came back and updated the post with a second method that could do the same thing - using the ServiceManager from inside a module and attaching the event that way.
voice your opinion now!
controller init method servicemanager event dispatch
Rob Allen's Blog: Module specific bootstrapping in ZF2
by Chris Cornutt March 08, 2012 @ 10:04:20
Rob Allen has a new post to his blog today looking at bootstrapping specific modules in a Zend Framework 2-based application without having to do the entire set.
Following on from the discussion on modules, we can hook into the event system to do module specific bootstrapping. By this, I mean, if you have some code that you want to run only if the action to be called is within this module, you can hook into the Application's dispatch event to achieve this.
He starts with an example of a basic module (Simple/Module.php) and shows how to define an "onBootstrap" method that calls the "onDispatch" method (when hooked to the event manager) to do some module-specific bootstrap operations. The RouteMatch feature is used to ensure that you're in the right controller/namespace combo to use the module.
voice your opinion now!
module bootstrap zendframework2 tutorial specific router dispatch
Matthew Weier O'Phinney's Blog: Simple Interfaces and Micro MVCs
by Chris Cornutt December 23, 2010 @ 09:29:07
In a new post to his blog today Matthew Weier O'Phinney takes a look at micro MVC frameworks and how, with just a bit of lightweight code and pieces of the Zend Framework, creating one is dead simple.
My job is great: I get to play with technology and code most days. My job is also hard: how does one balance both functionality and usability in programming interfaces? [...] One interface I've been toying with is inspired by two very different sources. The first is PHP's own SoapServer API (which we use already in our various server components); the other was a discussion I had with Fabien Potencier (of Symfony fame) a couple years ago, where he said the goal of Symfony 2 would be "to transform a request into a response."
The result is a simple Dispatachable interface that acts as the lowest level to build the whole MVC on top of. He illustrates with a micro MVC example that uses the Dispatchable interface to create a Dispatcher class to handle the incoming requests and attach various endpoints for handling. An example of it in use is also included.
voice your opinion now!
interface dispatch zendframework micromvc mvc
Zend Developer Zone: Zend Framework Dispatch Workflow Diagram
by Chris Cornutt May 13, 2009 @ 08:47:33
In this new post to the Zend Developer Zone, they point out a workflow diagram Polley Wong has come up with showing how the Zend Framework's dispatch system works (request handling).
I've been researching Zend Framework lately and was curious about what's actually happening behind the scene of the whole dispatch process. Inspired by Thorsten Ruf's (zenddispatch_en.pdf) clear and beautifully presented workflow, I decided to go a step deeper and crawl Zend Framework's code. I came up with my own version of the flexible yet complicated workflow.
You can check out this new PDF here. It diagrams out an overall view of the request handling, a look at what happens inside the front controller including components like the Controller Dispatcher, Action Controller, Action Helper Broker and Response Object.
voice your opinion now!
zendframework dispatch workflow diagram polleywong
Jani Hartikainen's Blog: Improving Ajax performance in Zend Framework applications
by Chris Cornutt March 23, 2009 @ 08:45:03
New on his blog Jani Hartikainen has posted a simple idea that you can take to make sure you're getting the most out of your Ajax/Zend Framework connections.
A common reason to use Ajax in a website is to make it feel faster, so you usually want Ajax requests be processed as quickly as possible. While there are many ways to speed up Zend Framework based applications, there are still some things like routing and dispatching which still add up to the total. There is, however, another way to make Ajax work even faster
Since Ajax requests don't usually require all of the complex routing and dispatching that a normal Zend Framework request might, he recommends creating a separate Ajax handler. His includes an example of a simple searching endpoint with a class handling the backend logic. A simple handler script loads up the bootstrap and makes the request for the search, returning the search results in a JSON format.
voice your opinion now!
improve ajax performance zendframework endpoint route dispatch
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!
|