psr/event-dispatcher
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The psr/event-dispatcher is a set of standard interfaces for event handling in PHP. Rather than being a standalone event dispatcher implementation, it provides interfaces which outline the necessary components an event dispatcher should contain. The event dispatcher plays an essential part in designing and managing your apps' events so that they react in response to particular user actions or system-generated events.
You utilize psr/event-dispatcher by integrating it into your event-driven PHP applications. However, it's crucial to note that as this package only contains interfaces, you'll have to provide your own implementations or use an event dispatcher which adheres to these interfaces. Here's an example of how you could potentially use it:
<?php
use Psr\EventDispatcher\StoppableEventInterface;
class YourEvent implements StoppableEventInterface
{
private bool $stoppable;
public function __construct(bool $stoppable = true)
{
$this->stoppable = $stoppable;
}
public function isPropagationStopped(): bool
{
return $this->stoppable;
}
}
$event = new YourEvent();
// Your event dispatcher will use the $event instance.
The documentation for the psr/event-dispatcher package can be found at PSR-14 on the official PHP-FIG website. You'll find detailed explanations about each interface provided by this package, the event dispatcher specifications, as well as the event and speaker patterns generally used within PHP applications. Please remember to consult the documentation frequently while writing applicable codes to ensure adherence to the recommended guidelines.