Event Manager

ZF2 – Event Manager – Zend\EventManager

The ZF2 Event Manager is a component designed to implement simple subject/observer patterns, aspect-oriented designs and implementing event-driven architectures.
To start with, it is worth taking a look at the onBootstrap() method of the ZF2 skeleton application within the ‘Application’ module.
// Application/Module.php
<?php

namespace Application;

use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;

class Module

ZF2 – Event Manager – Shared Event Manager

The ZF2 Shared Event Manager provides a way to attach listeners to many event managers. The SharedEventManager is an implementation of SharedEventManagerInterface.
As we saw the previous example (if you haven’t read the Event Manager article, you can do so here), creating an event manager class and trying to listen to an event did not …