The ServerGrove blog continues their spotlight on the various components that make up the Symfony2 framework in their latest post about the EventDispatcher.
For many years, in the PHP world we were used to code following a linear flow, where instructions were executed one after another, jumping to functions or methods. Events change the way we design our software and allow us to decouple different parts creating small and reusable classes with a well-defined goal.
The post includes a brief introduction to the Mediator design pattern and how the EventDispatcher implements it. Sample code is included showing how to make a dispatcher, add events and dispatch an event to a waiting listener. There's also a comparison between "event listeners" and "event subscribers", pointing out that the latter has more flexibility when it comes to event priority.