Indigo Supervisor Event
, (*1)
Listen to Supervisor events in PHP., (*2)
Install
Via Composer, (*3)
``` bash
$ composer require indigophp/supervisor-event, (*4)
## Usage
Supervisor has this pretty good feature: notify you(r listener) about it's events.
The main entry point is the `Listener`. `Listeners`s wait for a `Handler` in the main listening logic. `Handler`s get a `Notification` when an event occurs.
``` php
use Indigo\Supervisor\Event\Listener\Standard;
use Indigo\Supervisor\Event\Handler\Callback;
use Indigo\Supervisor\Event\Notification;
$handler = new Callback(function(Notification $notification) {
echo $notification->getHeader('eventname');
});
$listener = new Standard;
$listener->listen($handler);
Currently available listeners:, (*5)
- Standard: Listents to standard input stream, writes to standard output
- Guzzle: Uses
StreamInterface to provide an easy interface for reading/writting
Additionally you can use two exceptions to control the listeners itself:, (*6)
-
Indigo\Supervisor\Exception\StopListener: indicates that the Listener should stop listening for further events.
-
Indigo\Supervisor\Exception\EventHandlingFailed: indicates that handling the event failed, Listener should return with a FAIL response.
Any other unhandled exceptions/errors will cause the listener to stop., (*7)
Check the Supervisor docs for more about Events., (*8)
Testing
bash
$ phpspec run, (*9)
Contributing
Please see CONTRIBUTING for details., (*10)
Credits
License
The MIT License (MIT). Please see License File for more information., (*11)