Download the PHP package stk2k/eventstream without Composer
On this page you can find all versions of the php package stk2k/eventstream. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stk2k/eventstream
More information about stk2k/eventstream
Files in stk2k/eventstream
Package eventstream
Short Description A simple PHP pub-sub library
License MIT
Homepage https://github.com/stk2k/eventstream
Informations about the package eventstream
PHP simple pub-sub library
Description
You can use this library to build an application using simple pub-sub pattern. This library consists of three main objects below:
- EventStream
event stream is frontend facade of this system. you can push events to event source, register event listeners to event emitter, and flush events.
- EventSource
event source is an event provider. it has a role to provide events when event stream request. you have to declare event source, and call EventStream#source() method to attach source.
- EventEmitter
event emitter is an event dispatcher. it has a role to manage user callback functions. use Emitter/SimpleEventEmitter class for normal use, and pass it to EventStream#emitter() method.
Demo
01. event source
Usage
- create event stream object
- define your own event source class and attach new instance to stream.
- define your own event emitter or use bundled emitter classes and attach new instance to stream.
- define your own callback(s) and attach it(them) to stream or emitter.
- flush events in event source via EventStream#flush() method.
More Examples
- numbers.php: simple emitter and source sample
- multi_channel.php: listen different channel(event)s.
- regular_expression.php: single bind but listen multi channels by regular expression.
- wild_card.php: single bind but listen multi channels by wild card.
Requirement
PHP 7.2 or later
Installing stk2k/eventstream
The recommended way to install Calgamo/Bench is through Composer.
After installing, you need to require Composer's autoloader: