Gossip is a tiny event broadcasting library written by Selvin Ortiz
- PHP 5.4+
- Composer and selvinortiz/gossip
composer require selvinortiz/gossip
sh spec.sh
Event broadcasting is a fancy way of saying that Gossip allows you to register your responders to listen for a specific event and when that event is whispered, it can respond.
use SelvinOrtiz\Gossip\Gossip;
class App
{
public function init()
{
Gossip::instance()->whisper(new Event('app.init'));
}
public function end()
{
Gossip::instance()->whisper(new Event('app.end', [$this]));
}
public function log($message)
{
// Log a $message to db or file system
}
}
// Called when app.init is whisper()ed
Gossip::instance()->listen('app.init', function (Event &$event) {
// Bootstrap third party code, initialize services, etc.
});
// Called only the first time app.end is whisper()ed
Gossip::instance()->listenOnce('app.end', function (Event &$event, $app) {
// Close db connections, destroy sessions, etc.
$app->log('Application is ending...');
});
API reference is coming soon...
Gossip wants to be friendly to first time contributors. Just follow the steps below and if you have questions along the way, please reach out.
- Fork it!
- Create your bugfix or feature branch
- Commit and push your changes
- Submit a pull request
Gossip is open source software licensed under the MIT License