zmq

ZeroMQ bindings for ReactPHP.

  • Owner: friends-of-reactphp/zmq
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

React/ZMQ

ZeroMQ bindings for React.

Build Status

Install

The recommended way to install react/zmq is through composer.

composer require react/zmq

Example

And don't forget to autoload:

<?php
require 'vendor/autoload.php';

Here is an example of a push socket:

<?php

$loop = React\EventLoop\Factory::create();

$context = new React\ZMQ\Context($loop);

$push = $context->getSocket(ZMQ::SOCKET_PUSH);
$push->connect('tcp://127.0.0.1:5555');

$i = 0;
$loop->addPeriodicTimer(1, function () use (&$i, $push) {
    $i++;
    echo "sending $i\n";
    $push->send($i);
});

$loop->run();

And the pull socket that goes with it:

<?php

$loop = React\EventLoop\Factory::create();

$context = new React\ZMQ\Context($loop);

$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://127.0.0.1:5555');

$pull->on('error', function ($e) {
    var_dump($e->getMessage());
});

$pull->on('message', function ($msg) {
    echo "Received: $msg\n";
});

$loop->run();

Todo

  • Integration tests
  • Buffer limiting
  • Do not push messages if no listener

Tests

To run the test suite, you need PHPUnit.

$ phpunit

License

MIT, see LICENSE.

Main metrics

Overview
Name With Ownerfriends-of-reactphp/zmq
Primary LanguagePHP
Program languagePHP (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2012-05-26 22:23:33
Pushed At2018-05-18 15:28:48
Last Commit At2018-05-18 17:27:55
Release Count5
Last Release Namev0.4.0 (Posted on 2018-05-18 17:28:24)
First Release Namev0.1.0 (Posted on )
用户参与
Stargazers Count249
Watchers Count19
Fork Count49
Commits Count119
Has Issues Enabled
Issues Count34
Issue Open Count3
Pull Requests Count22
Pull Requests Open Count0
Pull Requests Close Count6
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private