PHP code example of parable-php / event

1. Go to this page and download the library: Download parable-php/event library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

parable-php / event example snippets


use \Parable\Event\Events;

$eventManager = new Events();

$eventManager->listen('event_number_one', function (string $event, string &$payload) {
    $payload .= '-updated!';
});

$payload = 'event';

$eventManager->trigger('event_number_one', $payload);

echo $payload;

// output: 'event-updated!'

$eventManager->listenAll(function (string $event, $payload) {
    echo $event . PHP_EOL;
});
bash
$ composer