Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
This package has been abandoned. Use laminas/laminas-eventmanager instead.

zendframework/zend-eventmanager 2.4.0rc7

Package summary
Share
0
issues
0
licenses
Package created
7 Feb 2013
Version published
23 Mar 2015
Maintainers
1
Total deps
0
Direct deps
0
License
BSD-3-Clause
Error Generating Report

Frequently Asked Questions

What does zendframework/zend-eventmanager do?

The zendframework/zend-eventmanager is a composer package designed to handle events within a PHP application. It majorly fulfils three use cases - implementing simple subject/observer patterns, aspect-oriented designs, and event-driven architectures. This architecture allows you to attach and detach listeners to named events, both on a per-instance basis as well as via shared collections, trigger events, and interrupt the execution of event listeners.

How do you use zendframework/zend-eventmanager?

To use the zendframework/zend-eventmanager, you need to first install it via composer. Here is a simple code example showing how to use this package:

use Zend\EventManager\EventManager;

$eventManager = new EventManager();
$eventManager->attach('do', function ($e) {
    $event  = $e->getName();
    $params = $e->getParams();
    printf(
        'Handled event "%s", with parameters %s',
        $event,
        json_encode($params)
    );
});

$params = ['foo' => 'bar', 'baz' => 'bat'];
$eventManager->trigger('do', null, $params);

In the example, we first import the EventManager from zendframework. We then create a new instance and attach an event 'do' to it. We also define an event handler function to handle this event. Then we trigger the event 'do' with some parameters.

Where are the zendframework/zend-eventmanager docs?

The in-depth documentation of zendframework/zend-eventmanager can be found directly on the official Zend Framework site at https://zendframework.github.io/zend-eventmanager/. This comprehensive guide will take you through from basic usage to advanced features of the package, with clear examples and descriptions. Make sure to read them if you're planning to use this package in your project. Additionally, you can find specific information about migrating from version 2 to version 3 in the migration documentation section.