supervisorphp / event
Listen to Supervisor events in PHP
Installs: 29 866
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 5
Forks: 2
Open Issues: 0
Requires
- php: >=7.3
Requires (Dev)
- guzzlehttp/streams: >=2.0
- overtrue/phplint: ^2.0
- phpspec/phpspec: ^6.2
- phpstan/phpstan: ^0.12.32
- phpstan/phpstan-strict-rules: ^0.12.2
Suggests
- guzzlehttp/streams: Used by Stream listener
README
Listen to Supervisor events in PHP.
Install
Via Composer
$ composer require supervisorphp/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.
$handler = new \Supervisor\Event\Handler\CallbackHandler(function(\Supervisor\Event\Notification $notification) { echo $notification->getHeader('eventname'); }); $listener = new \Supervisor\Event\Listener\StandardListener; $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:
Supervisor\Exception\StopListenerException
: indicates that theListener
should stop listening for further events.Supervisor\Exception\EventHandlingFailedException
: 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.