All Projects → repejota → Phpnats

repejota / Phpnats

Licence: mit
A PHP client for the NATSio cloud messaging system.

Projects that are alternatives of or similar to Phpnats

Nats.net
The official C# Client for NATS
Stars: ✭ 378 (+80.86%)
Mutual labels:  messaging, nats, message-bus, client
go-nats-examples
Single repository for go-nats example code. This includes all documentation examples and any common message pattern examples.
Stars: ✭ 99 (-52.63%)
Mutual labels:  messaging, message-bus, nats, message-queue
psr-container-messenger
Message bus and queue for Mezzio with Symfony Messenger + Enqueue
Stars: ✭ 24 (-88.52%)
Mutual labels:  messaging, message-bus, message-queue
Rebus
🚌 Simple and lean service bus implementation for .NET
Stars: ✭ 1,733 (+729.19%)
Mutual labels:  messaging, message-queue, message-bus
Nats Server
High-Performance server for NATS.io, the cloud and edge native messaging system.
Stars: ✭ 10,223 (+4791.39%)
Mutual labels:  messaging, message-queue, message-bus
Benthos
Fancy stream processing made operationally mundane
Stars: ✭ 3,705 (+1672.73%)
Mutual labels:  message-queue, nats, message-bus
Nats.c
A C client for NATS
Stars: ✭ 220 (+5.26%)
Mutual labels:  messaging, message-queue, message-bus
Liftbridge
Lightweight, fault-tolerant message streams.
Stars: ✭ 2,175 (+940.67%)
Mutual labels:  messaging, message-queue, nats
Nats.java
Java client for NATS
Stars: ✭ 325 (+55.5%)
Mutual labels:  messaging, nats, client
Nats.rb
Ruby client for NATS, the cloud native messaging system.
Stars: ✭ 850 (+306.7%)
Mutual labels:  messaging, nats, client
Foundatio
Pluggable foundation blocks for building distributed apps.
Stars: ✭ 1,365 (+553.11%)
Mutual labels:  messaging, message-bus
Simpletcp
Simple wrapper for TCP client and server in C# with SSL support
Stars: ✭ 99 (-52.63%)
Mutual labels:  messaging, client
Nats.ex
Elixir client for NATS, the cloud native messaging system. https://nats.io
Stars: ✭ 97 (-53.59%)
Mutual labels:  nats, client
Matrix Commander
simple but convenient CLI-based Matrix client app for sending and receiving
Stars: ✭ 90 (-56.94%)
Mutual labels:  messaging, client
Mq
MQ is a simple distributed in-memory message broker
Stars: ✭ 114 (-45.45%)
Mutual labels:  message-queue, message-bus
Sandglass
Sandglass is a distributed, horizontally scalable, persistent, time sorted message queue.
Stars: ✭ 1,531 (+632.54%)
Mutual labels:  messaging, message-queue
Py3 Pinterest
Fully fledged Python Pinterest client
Stars: ✭ 133 (-36.36%)
Mutual labels:  messaging, client
Rxmq.js
JavaScript pub/sub library based on RxJS
Stars: ✭ 134 (-35.89%)
Mutual labels:  message-queue, message-bus
Slimmessagebus
Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
Stars: ✭ 120 (-42.58%)
Mutual labels:  messaging, message-bus
Enqueue Dev
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro
Stars: ✭ 1,977 (+845.93%)
Mutual labels:  message-queue, message-bus

phpnats

Travis

Master Develop
Build Status Build Status

Coverage

Master Develop
Coverage Status Coverage Status

Introduction

A PHP client for the NATS messaging system.

Requirements

Usage

Installation

Let's start by downloading composer into our project dir:

curl -O http://getcomposer.org/composer.phar
chmod +x composer.phar

Now let's tell composer about our project's dependancies, in this case, PHPNats. The way we do this is by creating a composer.json file, and placing it in the root folder of our project, right next to composer.phar

{
  "require": {
    "repejota/nats": "dev-master"
  }
}

Let's let Composer work its magic:

php composer.phar install

Composer will download all the dependencies defined in composer.json, and prepare all the files needed to autoload them.

Basic Usage

$client = new \Nats\Connection();
$client->connect();

// Publish Subscribe

// Simple Subscriber.
$client->subscribe(
    'foo',
    function ($message) {
        printf("Data: %s\r\n", $message->getBody());
    }
);

// Simple Publisher.
$client->publish('foo', 'Marty McFly');

// Wait for 1 message.
$client->wait(1);

// Request Response

// Responding to requests.
$sid = $client->subscribe(
    'sayhello',
    function ($message) {
        $message->reply('Reply: Hello, '.$message->getBody().' !!!');
    }
);

// Request.
$client->request(
    'sayhello',
    'Marty McFly',
    function ($message) {
        echo $message->getBody();
    }
);

Encoded Connections

$encoder = new \Nats\Encoders\JSONEncoder();
$options = new \Nats\ConnectionOptions();
$client = new \Nats\EncodedConnection($options, $encoder);
$client->connect();

// Publish Subscribe

// Simple Subscriber.
$client->subscribe(
    'foo',
    function ($payload) {
        printf("Data: %s\r\n", $payload->getBody()[1]);
    }
);

// Simple Publisher.
$client->publish(
    'foo',
    [
     'Marty',
     'McFly',
    ]
);

// Wait for 1 message.
$client->wait(1);

// Request Response

// Responding to requests.
$sid = $client->subscribe(
    'sayhello',
    function ($message) {
        $message->reply('Reply: Hello, '.$message->getBody()[1].' !!!');
    }
);

// Request.
$client->request(
    'sayhello',
    [
     'Marty',
     'McFly',
    ],
    function ($message) {
        echo $message->getBody();
    }
);

Developer's Information

Releases

Tests

Tests are in the tests folder. To run them, you need PHPUnit and execute make test-tdd.

We also have a BDD test suite under the spec folder. To run the suite, you need PHPSpec and execute make test-bdd.

You can also execute the all suites ( TDD + BDD ) with make test.

Code Quality

We are using PHP Code Sniffer to ensure our code follow an high quality standard.

To perform an analysis of the code execute make lint.

There is currently three steps when we lint our code:

  • First we lint with php itself php -l
  • Then we lint with PSR2 standard
  • And finally we lint with a custom ruleset.xml that checks dockblocks and different performance tips.

Creators

Raül Pérez

License

MIT, see LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].