2017 © Pedro Peláez
 

library pubsub

Simple implementation of the PubSub design pattern in PHP

image

studio24/pubsub

Simple implementation of the PubSub design pattern in PHP

  • Wednesday, August 17, 2016
  • by simonrjones
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

PubSub

Simple implementation of the PubSub design pattern in PHP., (*1)

Installation

composer require studio24/pubsub

Usage

Import at the top of your PHP script via:, (*2)

use Studio24\PubSub\PubSub;

Add a task to run at a certain event (subscribe)

This will run the passed anonymous function when the event 'myevent' is run., (*3)

PubSub::subscribe('myevent', function($name){
    // My code goes here
    echo $name;
});

PubSub::subscribe($event, $callback, $weight)

Params:, (*4)

  • $event (string) Event name
  • $callback (callback) Callback function to run
  • $weight (int) Optional, weight to define the order subscribed tasks run, defaults to 10. The lower the number the earlier this callback runs

Run tasks at a certain event (publish)

This runs all tasks which are subscribed to the 'myevent' event, passing the argument $name., (*5)

PubSub::publish('myevent', $name);

PubSub::publish($event, ...$arguments)

Params:, (*6)

  • $event (string) Event name
  • $arguments (mixed) Optional, one or many arguments to pass to the callback function

License

The MIT License (MIT). Please see License File for more information., (*7)

Credits

The Versions

17/08 2016

dev-master

9999999-dev https://github.com/studio24/pubsub

Simple implementation of the PubSub design pattern in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

events messaging pubsub publish-subscribe

17/08 2016

v1.0.2

1.0.2.0 https://github.com/studio24/pubsub

Simple implementation of the PubSub design pattern in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

events messaging pubsub publish-subscribe

11/07 2016

v1.0.1

1.0.1.0 https://github.com/studio24/pubsub

Simple implementation of the PubSub design pattern in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

events messaging pubsub publish-subscribe

28/03 2016

v1.0.0

1.0.0.0 https://github.com/studio24/pubsub

Simple implementation of the PubSub design pattern in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

events messaging pubsub publish-subscribe