News Feed
Sections




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

Fabien Potencier's Blog:
Create your own framework... on top of the Symfony2 Components (part 5)
January 12, 2012 @ 10:48:17

Fabien Potencier has posted the fifth part of his series looking at building a custom framework on top of the Symfony2 components. In this new tutorial he adds in one of the major features of any framework - the controller level.

For simple pages like the ones we have created so far, that's not a problem, but if you want to add more logic, you would be forced to put the logic into the template itself, which is probably not a good idea, especially if you still have the separation of concerns principle in mind. Let's separate the template code from the logic by adding a new layer: the controller: The controller mission is to generate a Response based on the information conveyed by the client Request.

He updates the template rendering to use an external method instead of doing it itself and updates the routing to include a "_controller" attribute pointing to the method. The full code for the updated version of the framework is included - a simple request/response with handling for a "leap_year" route.

0 comments voice your opinion now!
framework symfony2 custom controller tutorial series


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Zend Framework Proposal Weeks Start June 12th

Script-Tutorials.com: Watermark processing on images using PHP and GD

Matthew Weier O'Phinney's Blog: Creating Re-Usable Zend_Application Resource Plugins

SitePoint PHP Blog: Build Virtual Machines Easily with PuPHPet Part 2

Rob Allen's Blog: Using Zend\Loader\Autoloader


Community Events

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


php7 opinion release podcast laravel wordpress example voicesoftheelephpant api framework version laravel5 introduction community series unittest library language interview extension

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