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:
Decoupling your (event) system
August 26, 2014 @ 11:15:17

Matthias Noback has continued his look at event handling in PHP applications (well, Symfony-related ones at least) in his latest post. In this latest post he focuses more on abstracting out the event handling process and decoupling it from your application as much as possible.

You are creating a nice reusable package. Inside the package you want to use events to allow others to hook into your own code. You look at several event managers that are available. [...] Introducing this dependency is not without any problem: everybody who uses my/package in their project will also pull in the [event dispatcher] package, meaning they will now have yet another event dispatcher available in their project (a Laravel one, a Doctrine one, a Symfony one, etc.). This doesn't make sense, especially because event dispatchers all do (or can do) more or less the same thing.

As mentioned, he focuses in on the Symfony ecosystem and the event handlers commonly used there. He talks about some of the disadvantages of the Symfony EventDispatcher and how its interface can lead to code bloat due to it's verbosity (flexibility?). He talks about its violations of the Interface Segregation Principle and how he would structure the listener setup and handling if he was starting from scratch. To this end, he's created an adapter that wraps around an EventDispatcher interface and works with objects for the different kinds of events rather than the string names.

0 comments voice your opinion now!
decouple event manager dispatch handling symfony adapter object

Link: http://php-and-symfony.matthiasnoback.nl/2014/08/symfony2-decoupling-your-event-system/

blog comments powered by Disqus

Similar Posts

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

Matthias Noback: Symfony2: How to create framework independent controllers?

Paul Reinheimer's Blog: Object-Oriented PHP, Concepts, Techniques, and Code

DevShed: The Basics of Implementing Adapter Objects with PHP

Fabien Potencier's Blog: Twitter and Emails are good; Postcards are better


Community Events





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


release symfony interview community podcast introduction package laravel series framework unittest language tips update deployment api zendserver install opinion library

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