PHP code example of hoa / core

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




mp(HOA); // bool(true)

$conf = 

Hoa\Registry\Registry::set('foo', 'bar');
echo resolve('hoa://Library/Registry#foo'); // bar

event('hoa://Event/Exception')->attach(function ($bucket) {
    $exception = $bucket->getData();
    echo 'Exception: ', $exception->getMessage(), "\n";
})

throw new Hoa\Core\Exception('Hello %s!', 0, 'Gordon');
// Exception: Hello Gordon!

$websocket = new Hoa\Websocket\Server(
    new Hoa\Socket\Server('tcp://127.0.0.1:8889')
);
$websocket->on('message', $callable);
$websocket->run();