PHP code example of denpa / laravel-zeromq

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

    

denpa / laravel-zeromq example snippets


'providers' => [
    ...
    Denpa\ZeroMQ\Providers\ServiceProvider::class,
];

'aliases' => [
    ...
    'ZeroMQ' => Denpa\ZeroMQ\Facades\ZeroMQ::class,
];

zeromq()->publish(['foo', 'bar'], 'hello');
zeromq()->connection('test')->publish(['foo', 'bar'], 'hello');

zeromq()->pull(function ($message) {
    echo $message;
});

zeromq()->push('hello');

zeromq()->subscribe(['foo', 'bar'], function ($message) {
    echo $message;
});

use Denpa\ZeroMQ\Facades\ZeroMQ;

$callback = function ($message) {
    echo $message;
};

// use default connection
ZeroMQ::publish(['foo', 'bar'], 'hello');
ZeroMQ::pull($callback);
ZeroMQ::push('hello');
ZeroMQ::subscribe(['foo', 'bar'], $callback);

// use different connection
ZeroMQ::connection('baz')->push('hello');

'zeromq' => [
    'driver' => 'zeromq',
],

bitcoind()->on('hashblock', function ($blockhash, $sequence) {
    // get hash of new best block and retrieve full block info
    $block = bitcoind()->getBlock($blockhash);
    print_r($block->get());
});