News Feed
Sections




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

Matthias Noback:
Symfony2 How to create framework independent controllers?
June 18, 2014 @ 09:15:16

Matthias Noback has a new post to his site today, the first part of a series, looking at making framework-independent controllers for use in a Symfony2 framework-based project.

The general belief is that controllers are the most tightly coupled classes in every application. Most of the time based on the request data, they fetch and/or store persistent data from/in some place, then turn the data into HTML, which serves as the response to the client who initially made the request. [...] In this post I demonstrate that this high level of coupling is definitely not necessary. I will show you how you can decrease coupling a lot by taking some simple steps. We will end with a controller that is reusable in different types of applications, e.g. a Silex application, or even a Drupal application.

In this first part he focuses on a few places where the common practices lead to some unnecessary coupling between the controller and framework:

  • Using the framework helper methods
  • Using dependency injection (manually injecting instead)
  • Making the controller a service instead

The next post in the series will look at the use of annotations and how to refactor them out of the controller to remove yet another coupling point.

0 comments voice your opinion now!
framework independent controller symfony2 tutorial refactor decouple

Link: http://php-and-symfony.matthiasnoback.nl/2014/06/how-to-create-framework-independent-controllers/

blog comments powered by Disqus

Similar Posts

SitePoint PHP Blog: The Joy of Regular Expressions [2]

Till Klampaeckel's Blog: So you'd like to migrate from MySQL to CouchDB? - Part II

Zend Developer Zone: Zend_Acl and MVC Integration Part II (Advanced Use)

SitePoint PHP Blog: How to Create Your Own Twitter Widget in PHP, Part 3

SitePoint PHP Blog: Creating a Subscription-Based Website with Laravel and Recurly, Part 1


Community Events





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


community release language interview configure list unittest developer opinion testing threedevsandamaybe code framework wordpress install series introduction podcast laravel refactor

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