Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Zend Eventmanager Laravel Package

zendframework/zend-eventmanager

Zend\EventManager provides a lightweight, flexible event and listener system for PHP apps. Attach and detach listeners, trigger events with priorities, and use shared managers for cross-cutting events—ideal for decoupling components in Zend Framework and beyond.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install via Composer: composer require zendframework/zend-eventmanager
  • Core concepts: EventManager, EventManagerInterface, ListenerAggregateInterface, and SharedEventManagerInterface
  • Minimal usage: Instantiate EventManager, attach a listener with attach(), trigger an event with trigger()
  • First use case: Decoupling logic in a service class (e.g., notify external systems when a user is created)
  • Start by reading src/EventManager.php and src/ListenerAggregateInterface.php for foundational APIs

Implementation Patterns

  • Use SharedEventManager to listen to events across multiple classes (e.g., UserCreated event triggered by both CLI and HTTP handlers)
  • Implement ListenerAggregateInterface for grouped, reusable listeners (cleaner than scattered attach() calls)
  • Prefer EventManagerInterface::triggerUntil() or trigger() with callback-based listeners to early-exit on conditions
  • Integrate with PSR-14 compatibility via wrapper classes (e.g., Zend\EventManager\PSR14\EventWrapper)
  • Use EventInterface (e.g., Event) to carry context (target object, name, params) between components
  • Centralize event names as constants (e.g., UserEvents::CREATED) to avoid typos

Gotchas and Tips

  • ⚠️ Package is archived (no active development); consider migrating to psr/event-dispatcher for long-term support
  • Listener priority is critical: lower numbers run first; omitting priority defaults to 1
  • Shared listeners only fire if the triggering EventManager is configured with a SharedEventManagerInterface (common source of missing events)
  • Debug tip: Use EventManager::setIdentifiers() to scope events per context (e.g., per-request or per-object identity)
  • Beware circular references when listeners trigger new events—use getParams()/setParams() carefully or clone objects
  • Extension: Extend EventManager or use EventManagerSharedTrait in your base classes for consistent event behavior
  • For high-performance scenarios, avoid heavy logic in listeners—defer with queues or async workers where possible
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport