sabre/event
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Sabre/event is a lightweight library dedicated to event-based programming in PHP. It comes with features such as an EventEmitter, Promises, an event loop, and Co-routines to bring flexibility and performance benefits in handling different programming events.
To start using sabre/event in your programs, you'll need to have composer installed. Once you've sorted that, you can simply run composer require sabre/event "^5.0"
in your terminal. This will fetch and install the library into your PHP project. Please note, the package requires PHP version 7.1.
Here's a simple example of how you can use the sabre/event:
// Require the composor autoload for sabre/event
require 'vendor/autoload.php';
// Instantiate event emitter
$eventEmitter = new \Sabre\Event\EventEmitter();
// Set up a listener for 'foo' event
$eventEmitter->on('foo', function () {
echo "foo event got triggered!";
});
// Trigger the 'foo' event
$eventEmitter->emit('foo');
In this example, we setup a very basic listener for an event named 'foo'. Whenever 'foo' event is emitted ($eventEmitter->emit('foo')
), the listener we setup will execute and print the message "foo event got triggered!".
Complete and detailed documentation of sabre/event can be found at: https://sabre.io/event/. The documentation explains all the event-based concepts and how to use the library efficiently. If you still have questions or issues, don't hesitate to open a ticket on GitHub at https://github.com/fruux/sabre-event/issues/.