PHP Classes

Observable PHP Event Listener and Emitter: Listen and emit events handled by callbacks

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 69 All time: 10,310 This week: 96Up
Version License PHP version Categories
php-event 1.0GNU General Publi...5PHP 5, Language
Description 

Author

This package can be used to listen and emit events handled by callbacks.

It can register an event handler by name and associate a callback function to handle that event.

The package can also emit an event with a given name passing some parameters and make the previously registered event handlers be called.

Picture of Carlos Carvalho
  Performance   Level  
Name: Carlos Carvalho <contact>
Classes: 8 packages by
Country: Brazil Brazil
Innovation award
Innovation award
Nominee: 2x

Example

<?php

require_once __DIR__ . '/vendor/autoload.php';
$emitter = \COC\Event\Emitter::getInstance();

$emitter->on('evm.createdUser', function($name, $lastname){
    print(
"hello {$lastname}, {$name} welcome!!");
});

$emitter->emit('evm.createdUser','Carlos','Carvalho');


Details

Events fire

Is simple observable events for php

Codacy Badge Latest Stable Version Total Downloads Latest Unstable Version License

Install

 composer require carlosocarvalho/event

usage

<?php

$emitter = \COC\Event\Emitter::getInstance();

$emitter->on('evm.createdUser', function($name, $lastname){
    print("hello {$lastname}, {$name} welcome!!");
});

$emitter->emit('evm.createdUser','Firstname','Lastname');

  Files folder image Files (10)  
File Role Description
Files folder imagespec (1 file)
Files folder imagesrc (4 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file readme.md Doc. Example script
Accessible without login Plain text file _config.yml Data Auxiliary data

  Files folder image Files (10)  /  spec  
File Role Description
  Plain text file Emitter.spec.php Class Class source

  Files folder image Files (10)  /  src  
File Role Description
  Plain text file DoubleEventException.php Class Class source
  Plain text file Emitter.php Class Class source
  Plain text file Listener.php Class Class source
  Plain text file SubscribeContract.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:69
This week:0
All time:10,310
This week:96Up