News Feed
Sections




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

Richard Miller's Blog:
Symfony2 Moving Away From the Base Controller
June 14, 2011 @ 13:23:15

Richard Miller has a new post to his blog today that recommends moving away from the base controller the Symfony introductory documentation has you make. He suggests an alternative that can be used more widely.

In fact, it is the advised best practice for controllers in shared bundles. When you do, you will no longer have access to these useful methods, in this post I am going to look at how to accomplish the same tasks without them. I have created a simple controller for some basic form interaction with a model which uses the base controllers methods. I am going to go through how to change this to a service which does not extend the base controller.

He starts with his "TestimonialController" that does some of the basic CRUD operations on the testimonial information. He shows you, step-by-step, the refactoring needed to stop using things like the default controller helpers (each with replacement code). With those removed, he can move to extend "ContainerAware" instead of "Controller", make the controller a service and doing some dependency injection for needed resources.

0 comments voice your opinion now!
base controller symfony refactor dependency


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Interview w/Francois Zaninotto & Fabien Potencier (Definitive Guide to symfony)

Gonzalo Ayuso: Auto injecting dependencies in PHP objects

Stefan Koopmanschap's Blog: Serving frontend and backend from the same document root with symfony

Fabien Potencier: SensioLabs raises 5 million euros to boost the Symfony ecosystem

Mike Purcell's Blog: Symfony - sfGuardPlugin - Use Email Instead of Username


Community Events





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


community zendserver series list podcast developer language interview development laravel version code deployment introduction release api conference application tips framework

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