reestyle/peavents

Basic event handler

dev-master 2020-08-09 00:00 UTC

This package is auto-updated.

Last update: 2024-03-29 04:18:51 UTC


README

Introduction

Peavents stands for PHP events - with a twist. I just thought throwing in a pea would be fun... :)

Peavents is a basic event system. Sort of like a hook system, but slightly different.

Requirements

  • PHP 7.0+

This project makes use of datatype type hinting and return value type. Both classes are based on ArrayObject classes.

Installation

Use composer:

$ composer require reestyle/peavents

Remember to use the autoloader.

Basic usage:

    $registry = \Peavents\Registry::instance();
    
    $event = $registry->make('event_name');
    
    $event
        ->setParams(['hello world'])
        ->attach(function($a) {
            print $a;
        })
        ->attach(function($a) {
            print ' - and another ' . $a;
        });
        
    $registry->raise('event_name');