Skip to content

Latest commit

 

History

History
73 lines (56 loc) · 2.01 KB

README.md

File metadata and controls

73 lines (56 loc) · 2.01 KB

Gossip

Build Status Total Downloads Latest Stable Version

Description

Gossip is a tiny event broadcasting library written by Selvin Ortiz

Requirements

Install

composer require selvinortiz/gossip

Test

sh spec.sh

Usage

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

API reference is coming soon...

Contribute

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.

  1. Fork it!
  2. Create your bugfix or feature branch
  3. Commit and push your changes
  4. Submit a pull request

License

Gossip is open source software licensed under the MIT License