PHPackages                             settermjd/mezzio-eventmanager-integration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. settermjd/mezzio-eventmanager-integration

ActiveLibrary[HTTP &amp; Networking](/categories/http)

settermjd/mezzio-eventmanager-integration
=========================================

This is a small package that simplifies integrating laminas-eventmanager with Mezzio projects built with the Mezzio Skeleton.

0.2.1(1y ago)321BSD-3-ClausePHPPHP ^8.3 || ^8.4CI passing

Since May 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/settermjd/mezzio-eventmanager-integration)[ Packagist](https://packagist.org/packages/settermjd/mezzio-eventmanager-integration)[ Fund](https://funding.communitybridge.org/projects/laminas-project)[ RSS](/packages/settermjd-mezzio-eventmanager-integration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (4)Used By (0)

Mezzio / Laminas EventManager Integration
=========================================

[](#mezzio--laminas-eventmanager-integration)

This project provides a simplistic way of integrating laminas-eventmanager with Mezzio projects that are (originally) scaffolded with [the Mezzio Skeleton](https://docs.mezzio.dev/mezzio/), making it almost trivial to subscribe listeners to events.

Tip

If you're new to Mezzio, check out [Mezzio Essentials](https://mezzioessentials.com) a practical, hands-on guide, which steps you through how to build an application, from start to finish.

Prerequisites
-------------

[](#prerequisites)

To use this project, you need the following:

- Composer installed globally
- PHP 8.3 or 8.4

Usage
-----

[](#usage)

To use the package with an existing Mezzio application, use Composer to add the package as a dependency to your project, as in the following example:

```
composer require mezzio-eventmanager-integration
```

### How to subscribe listeners to events

[](#how-to-subscribe-listeners-to-events)

Then, to subscribe listeners to events, you need to do two things:

1. Add a `listeners` element to the application's configuration, listing the events and the listeners that are subscribed to those events, along with the [priority](https://docs.laminas.dev/laminas-eventmanager/tutorial/#keeping-it-in-order) to subscribe them at (which is optional). There are three things to be aware of here:
    - If you don't assign a priority, a listener will be subscribed with a default priority of **1**
    - Higher priority values execute **earlier**
    - Lower (negative) priority values execute **later**
2. The listeners **must** be registered as services in the DI container.

There are many ways to add a `listeners` element to the application's configuration, but likely the simplest is to create a new file in the *config/autoload* directory named *listeners.global.php*, and in that file add a configuration similar to the example below.

```
