PHP code example of gamegos / events

1. Go to this page and download the library: Download gamegos/events 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/ */

    

gamegos / events example snippets


$eventManager = new Gamegos\Events\EventManager();
// Attach a callback to an event named 'foo'.
$eventManager->attach(
    'foo',
    function (Gamegos\Events\EventInterface $e) {
        echo sprintf('Handled "%s" event with subject "%s".', $e->getName(), $e->getSubject());
    }
);
// Trigger the 'foo' event with a subject ('bar').
$eventManager->trigger('foo', 'bar');