File: intro.md

package info (click to toggle)
php-zend-eventmanager 3.14.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 896 kB
  • sloc: php: 3,542; xml: 696; makefile: 17
file content (25 lines) | stat: -rw-r--r-- 1,053 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Lazy Listeners

Lazy listeners are a new feature in version 3.0, provided to reduce the
performance overhead of fetching listeners and/or aggregates from a Dependency
Injection Container until they are actually triggered.

The feature consists of three classes:

- `Laminas\EventManager\LazyListener`, which provides basic capabilities for
  wrapping the retrieval of a listener from a container and invoking it.
- `Laminas\EventManager\LazyEventListener`, which extends `LazyListener` but adds
  awareness of the event and optionally priority to use when attaching the
  listener. These are primarily used and created by:
- `Laminas\EventManager\LazyListenerAggregate`, which can take a list of
  `LazyEventListeners` and/or their definitions, and be used as an aggregate
  listener for attaching the lazy listeners to an event manager.

## Preparation

In order to use the lazy listeners feature, you will need to install
[PSR-11](https://www.php-fig.org/psr/psr-11/) Container, if you haven't already:

```bash
$ composer require psr/container
```