News Feed
Jobs Feed
Sections




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

PHPMaster.com:
An Introduction to the Front Controller Pattern, Part 2
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.

0 comments voice your opinion now!
frontcontroller designpattern introduction response request dispatch route


blog comments powered by Disqus

Similar Posts

Mayflower Blog: Creating coding standards for PHP_CodeSniffer

Michael Nitschinger's Blog: Caching responses in Lithium

SitePoint PHP Blog: Stored Procedures in MySQL and PHP

Jani Hartikainen's Blog: Decoupling models from the database: Data Access Object pattern in PHP

PHPit.net: A beginners introduction to PHP\'s file functions


Community Events











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


symfony2 hack security facebook hhvm framework podcast series component release package language application install composer overview dependency opinion unittest introduction

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