indigophp / supervisor-event
Listen to Supervisor events in PHP
Requires
- php: >=5.4.0
Requires (Dev)
- guzzlehttp/streams: >=2.0.0
- henrikbjorn/phpspec-code-coverage: ~1.0.0
- phpspec/phpspec: ~2.1.0
Suggests
- guzzlehttp/streams: Used by Stream listener
This package is not auto-updated.
Last update: 2022-02-01 12:43:18 UTC
README
DEPRECATION NOTICE
This package has been moved under SupervisorPHP.
For details see http://supervisorphp.com
Indigo Supervisor Event
Listen to Supervisor events in PHP.
Install
Via Composer
$ composer require indigophp/supervisor-event
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.
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:
- 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:
Indigo\Supervisor\Exception\StopListener
: indicates that theListener
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.
Check the Supervisor docs for more about Events.
Testing
$ phpspec run
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.