Download the PHP package fast-forward/event-dispatcher without Composer

On this page you can find all versions of the php package fast-forward/event-dispatcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package event-dispatcher

Fast Forward Event Dispatcher

PHP Version Composer Package PSR-14 Tests Coverage Docs GitHub Sponsors

A lightweight PSR-14 event dispatcher for PHP 8.3+ with named events, Symfony-style subscribers, attribute-based listeners, and first-class integration with the Fast Forward container.

✨ Features

📦 Installation

Install the package with Composer:

Requirements:

If you want to register Symfony-style subscribers or use #[AsEventListener], also install:

🛠️ Usage

1. Dispatch a typed PSR-14 event

The Fast Forward service provider wires the dispatcher and classifies configured listeners by strategy.

Output:

2. Dispatch the same event with an explicit name

Use a named dispatch when you want string-based routing in addition to the event class itself.

3. Use priorities with #[AsEventListener]

Attribute-based listeners are detected and routed to a priority-aware provider automatically.

4. Observe listener failures with ErrorEvent

When a listener throws, the dispatcher emits an ErrorEvent and then rethrows the original exception. This gives you a clean place to log, trace, or notify without swallowing the failure.

5. Log every dispatched object with a wildcard listener provider

WildcardListenerProvider is a small base class for providers that should observe every dispatched object. LogEventListenerProvider builds on it and sends each dispatch to a PSR-3 logger, including NamedEvent wrappers produced by named dispatch.

Output:

See examples/06-log-all-events.php for the runnable version.

6. Understand the dispatch flow

For each dispatched object, the library follows this sequence:

  1. Resolve listeners for the original event object.
  2. Invoke listeners until propagation stops or a listener throws.
  3. If the event is not already a NamedEvent, dispatch a named wrapper using the explicit name or the event class.
  4. If a listener throws, emit ErrorEvent.
  5. Rethrow the original throwable after error listeners have been notified.

🧰 API Summary

Class / Interface Purpose
EventDispatcher Main dispatcher that runs listeners, dispatches named wrappers, and emits ErrorEvent
Event\NamedEvent Wraps an event with an explicit dispatch name
Event\Event Generic Symfony-compatible base event with public stopPropagation()
Event\StoppableEventTrait Reusable propagation state for your own event classes
Event\ErrorEvent Error envelope emitted when a listener throws
Listener\LogErrorEventListener PSR-3 logger integration for ErrorEvent
ListenerProvider\WildcardListenerProvider Base class for providers that should observe every dispatched object
ListenerProvider\LogEventListenerProvider PSR-3 logging provider for all dispatched objects, named wrappers, and error events
ListenerProvider\EventSubscriberListenerProvider Adapts Symfony EventSubscriberInterface to PSR-14
ServiceProvider\EventDispatcherServiceProvider Registers dispatcher services and config-driven provider extensions
ServiceProvider\Configuration\ConfiguredListenerProviderCollection Classifies configured listeners into provider strategies

🔌 Integration

This package fits well in two modes:

Out of the box, the Fast Forward integration understands these listener styles:

📊 Listener Registration Styles

Style Example registration Best for Priority support
Invokable listener SendWelcomeEmailListener::class Simple one-event listeners Via provider order
#[AsEventListener] ReserveStockListener::class Declarative listeners with local metadata ✅
Symfony subscriber BillingSubscriber::class One class handling multiple events ✅
Wildcard provider LogEventListenerProvider::class Cross-cutting logging, metrics, and auditing Provider-defined
Custom provider DelegatingListenerProvider::class Advanced routing, delegation, composition Provider-defined

📁 Directory Structure Example

⚙️ Advanced and Customization

Mix listener strategies in one configuration

The service provider classifies each configured item and routes it to the matching provider. That means you can combine plain callables, attributed listeners, subscribers, and custom providers in the same app.

Create stoppable domain events

Build wildcard observers

When you need one listener-provider to observe every dispatched object, extend ListenerProvider\WildcardListenerProvider. This is useful for logging, metrics, auditing, and other cross-cutting concerns that should not depend on one event class.

Choose between Event and StoppableEventTrait

Use FastForward\EventDispatcher\Event\Event when you want a generic base class compatible with Symfony's event contract and you are fine with a public stopPropagation() method.

Use Event\StoppableEventTrait when you need the same stoppable behavior but your event already extends another class and cannot inherit from Event.

Log failures without hiding them

LogErrorEventListener is intentionally observational. It helps you record failures, but the dispatcher still rethrows the original exception so your application can fail fast when it should.

🛠️ Versioning and Breaking Changes

❓ FAQ

Do I need the Fast Forward container to use this package?

No. The core EventDispatcher only needs a PSR-14 ListenerProviderInterface. The Fast Forward service provider is the convenience layer that makes configuration and listener discovery ergonomic.

When should I use named events?

Use named events when your application already relies on string-based event identifiers, or when you want to expose a stable semantic name that is different from the PHP class name.

Do Symfony subscribers and attributes work out of the box?

They work with this package, but they rely on Symfony's event-dispatcher component types. If your project does not already include them, add symfony/event-dispatcher.

What happens if a listener throws an exception?

The dispatcher emits ErrorEvent, gives your error listeners a chance to observe the failure, and then rethrows the original exception.

How do I log every dispatched event?

Register LogEventListenerProvider or create your own subclass of WildcardListenerProvider. Wildcard providers receive the original event object and the generated NamedEvent wrapper when named dispatch is used.

🛡️ License

This library is released under the MIT License.

Copyright (c) 2025-2026 Felipe Sayão Lobato Abreu.

🤝 Contributing

Contributions, issues, and pull requests are welcome.

Useful local commands:

When changing behavior, keep the examples and this README in sync with the code.

🔗 Links


All versions of event-dispatcher with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
container-interop/service-provider Version ^0.4.1
fast-forward/container Version ^1.6
fast-forward/defer Version ^1.0
fast-forward/iterators Version ^1.2
phly/phly-event-dispatcher Version ^1.5
psr/container Version ^2.0
psr/event-dispatcher Version ^1.0
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/log Version ^3.0
psr/simple-cache Version ^3.0
symfony/event-dispatcher-contracts Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fast-forward/event-dispatcher contains the following files

Loading the files please wait ...