swoole / zmq
ZeroMQ bindings for Swoole.
Installs: 1 509
Dependents: 0
Suggesters: 0
Security: 0
Stars: 37
Watchers: 7
Forks: 11
Open Issues: 4
Requires
- php: >=5.4.0
- ext-zmq: *
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is auto-updated.
Last update: 2024-10-15 17:14:30 UTC
README
ZeroMQ bindings for Swoole.
Install
The recommended way to install swoole/zmq is through composer.
{ "require": { "swoole/zmq": "0.1.*" } }
composer require swoole/zmq
Example
And don't forget to autoload:
<?php require 'vendor/autoload.php';
Here is an example of a push socket:
$zmq = new Swoole\Async\ZMQ(); $zmq->on('Message', function ($msg) { echo "Received: $msg\n"; }); $zmq->bind('tcp://0.0.0.0:9530');
And the pull socket that goes with it:
$zmq = new Swoole\Async\ZMQ(); $zmq->connect('tcp://0.0.0.0:5555'); Swoole\Timer::tick(1000, function () use ($zmq) { static $i = 0; $msg = "hello-" . $i++; echo "Sending: $msg\n"; $zmq->send($msg); });