PHP code example of hoa / event

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

    

hoa / event example snippets


Hoa\Event\Event::getEvent('hoa://Event/Exception')->attach(
    function (Hoa\Event\Bucket $bucket) {
        var_dump(
            $bucket->getSource(),
            $bucket->getData()
        );
    }
);

Hoa\Event\Event::getEvent('hoa://Event/Exception')->attach(
    new Hoa\File\Write('Foo.log')
);

$server = new Hoa\Websocket\Server(…);
$server->on('message', function (Hoa\Event\Bucket $bucket) {
    var_dump(
        $bucket->getSource(),
        $bucket->getData()
    );
});