Download the PHP package effectra/event-dispatcher without Composer
On this page you can find all versions of the php package effectra/event-dispatcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download effectra/event-dispatcher
More information about effectra/event-dispatcher
Files in effectra/event-dispatcher
Package event-dispatcher
Short Description The Effectra Event Dispatcher package.
License MIT
Informations about the package event-dispatcher
Effectra Event Dispatcher
Effectra\EventDispatcher is a versatile and lightweight event dispatching library for PHP, designed to simplify the management of events within your application. It adheres to the PSR-14 standard, providing a consistent and extensible way to handle events, listeners, and event propagation.
Features
- PSR-14 Compliance: Follows the PSR-14 standard for event dispatching, ensuring interoperability with other PHP packages and frameworks.
- Stoppable Events: Supports stoppable events, allowing events to be halted during propagation if necessary.
- Flexible Listener Providers: Easily register and manage listeners for specific events through a flexible listener provider interface.
- Consistent Event Handling: Ensures synchronous execution of listeners in the order they are registered.
- Simplified API: Provides a straightforward API for dispatching events, making it easy to integrate into your projects.
Installation
You can install Effectra\EventDispatcher via Composer. Run the following command in your project directory:
Usage
1. Creating Events
Create your custom event classes by extending the Effectra\EventDispatcher\Event
class. This base class implements the Psr\EventDispatcher\StoppableEventInterface
, allowing events to be stoppable.
2. Registering Listeners
Create listeners by defining callable functions or classes implementing the necessary logic. Register listeners using the Effectra\EventDispatcher\ListenerProvider
class.
3. Stoppable Events
To create a stoppable event, use the stopPropagation()
method within your event logic. This will prevent further listeners from being executed.
Contributing
Contributions are welcome! Fork the repository, create a branch, make your changes, and then create a pull request. Please ensure your PR description clearly describes the changes you made.
License
This package is licensed under the MIT License.