Tag Archives: zend framework 2

Zend Framework 2: The input was not found in the haystack

Hello friends, When you use select input element in Zend Framework 2 forms, then in some cases we will get an error given below:

How to fix this issue? There are two solutions to resolve this issue. Solution 1: Assign all available values of select input element before setData() method. Let’s we have a… Read More »

Zend Framework 2: Using Redis with Zend Framework 2

Hello friends, Here we will see how can we use Redis with Zend Framework 2. Step 1: Install Redis First update your system’s package repositories and ensure the all installed packages are up to date. After that you can install Redis.

Step 2: Configure Redis All Redis configuration options are specified in /etc/redis/redis.cong file.… Read More »

Zend Framework 2: Create custom controller plugin

Hello friends, Here, we will see how to create a custom controller plugin in Zend Framework 2. Step 1: We can create our custom controller plugin anywhere as per our need. By default, controller plugin will be created under module\Application\src\Application\Controller\Plugin folder. Lets consider the controller plugin class file name is CustomPlugin.php under above specified path.… Read More »

Zend Framework 2: Shared Event Manager

Hello friends, Today will will discuss the use of Shared Event Manager and Listeners. A Shared Event Listeners is just a listener that has been attached to the Shared Event Manager (SEM) instead of the local Event Manager (EM) instance.


Zend Framework 2: Aggregate Listeners

Hello friends, Today we will discuss about the aggregate listeners. The Aggregate Listener is a listener that knows how to attach itself. In order to create an Aggregate Listener, you must use the following classes:  Zend\EventManager\ListenerAggregateInterface;  Zend\EventManager\EventManagerInterface; Step 1: Create a custom class CustomAggregateListeners.php

Step 2: Trigger events having aggregate listeners


Zend Framework 2: How to access event manager from every place

Hello friends, There are many situations where you faced a problem when you are not able to access event manager at some places. This may lead to lengthy code or may be change in the implementation logic. For solving this problem, zend framework 2 provides interface Zend\EventManager\EventManagerAwareInterface. There are two ways: a) You will have… Read More »

Zend Framework 2: Create/Manage Custom Events and Listeners

Hello friends, There are certain situations where we need some specific tasks to be done at some places only instead on entire application. For this, zend framework 2 provides event manager component which allows you to create events and listeners for those events when they occur. One more important point is that create events and… Read More »

Zend Framework 2: Controller specific event management

Hello friends, Today I am going to explain how can we attach events for each controller. If you noticed while creating any controller, we extend controller by abstract class Zend\Mvc\Controller\AbstractActionController which extends abstract class AbstractController. Here we have some important functions in these two abstract class like onBootstrap(), attachDefaultListeners(), setEventManager(), etc.

Thanks :).