PHPackages                             lishelun/nsq - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. lishelun/nsq

ActiveLibrary[HTTP &amp; Networking](/categories/http)

lishelun/nsq
============

NSQ Client for PHP

0.9.1(2y ago)0389MITPHPPHP ^8.1

Since Dec 14Pushed 2y agoCompare

[ Source](https://github.com/lishelun/nsqphp)[ Packagist](https://packagist.org/packages/lishelun/nsq)[ Docs](https://github.com/nsqphp/nsqphp)[ RSS](/packages/lishelun-nsq/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (18)Versions (2)Used By (0)

Nsq PHP
=======

[](#nsq-php)

[![](https://github.com/nsqphp/nsqphp/raw/master/docs/logo.png)](https://github.com/nsqphp/nsqphp/raw/master/docs/logo.png)

PHP Client for [NSQ](https://nsq.io/).

[![Latest Stable Version](https://camo.githubusercontent.com/bc04320db312c6eeb24a710d2de74d08adbebfaeb89fe6a2d1b02a01b776421b/68747470733a2f2f706f7365722e707567782e6f72672f6e73712f6e73712f76)](//packagist.org/packages/nsq/nsq) [![Total Downloads](https://camo.githubusercontent.com/dd17af9749fee8435438c3227660fe64cd81b3d24b11add34cf2d4709b2ded29/68747470733a2f2f706f7365722e707567782e6f72672f6e73712f6e73712f646f776e6c6f616473)](//packagist.org/packages/nsq/nsq) [![License](https://camo.githubusercontent.com/914294fe70e8f7817c027985b976773e07c4d30dece9e2dbf6efb9a5416d3e6b/68747470733a2f2f706f7365722e707567782e6f72672f6e73712f6e73712f6c6963656e7365)](//packagist.org/packages/nsq/nsq)[![codecov](https://camo.githubusercontent.com/6d88e933aaab573c46402f158e163773ca3865ae844ad8ca2b9225a8943d43fb/68747470733a2f2f636f6465636f762e696f2f67682f6e73717068702f6e73717068702f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4159554d43334f4f3242)](https://codecov.io/gh/nsqphp/nsqphp) [![Mutation testing badge](https://camo.githubusercontent.com/f5ab8388b37c8c629fe576aa7f628d045dc42eab4c3fc67a0b3218a934b07b05/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532466e73717068702532466e73717068702532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/nsqphp/nsqphp/master) [![telegram](https://raw.githubusercontent.com/aleen42/badges/master/src/telegram.svg)](http://t.me/grachevko)

This library follow [SemVer](https://semver.org/). Until version 1.0 will be released anything MAY change at any time, public API SHOULD NOT be considered stable. If you want use it before stable version was released install strict version without range.

Installation
------------

[](#installation)

This library is installable via [Composer](https://getcomposer.org/):

```
composer require nsq/nsq
```

Requirements
------------

[](#requirements)

This library requires PHP 8.0 or later.

Although not required, it is recommended that you install the [phpinnacle/ext-buffer](https://github.com/phpinnacle/ext-buffer) to speed up [phpinnacle/buffer](https://github.com/phpinnacle/buffer) .

Features
--------

[](#features)

- PUB
- SUB
- Feature Negotiation
- Discovery
- Backoff
- TLS
- Deflate
- Snappy
- Sampling
- AUTH

Usage
-----

[](#usage)

### Producer

[](#producer)

```
use Nsq\Producer;

$producer = Producer::create(address: 'tcp://nsqd:4150');

// Publish a message to a topic
$producer->publish('topic', 'Simple message');

// Publish multiple messages to a topic (atomically)
$producer->publish('topic', [
    'Message one',
    'Message two',
]);

// Publish a deferred message to a topic
$producer->publish('topic', 'Deferred message', delay: 5000);
```

### Consumer

[](#consumer)

```
use Nsq\Consumer;
use Nsq\Message;

$consumer = Consumer::create(
    address: 'tcp://nsqd:4150',
    topic: 'topic',
    channel: 'channel',
    onMessage: static function (Message $message): Generator {
        yield $message->touch(); // Reset the timeout for an in-flight message
        yield $message->requeue(timeout: 5000); // Re-queue a message (indicate failure to process)
        yield $message->finish(); // Finish a message (indicate successful processing)
    },
);
```

### Lookup

[](#lookup)

```
use Nsq\Lookup;
use Nsq\Message;

$lookup = new Lookup('http://nsqlookupd0:4161');
$lookup = new Lookup(['http://nsqlookupd0:4161', 'http://nsqlookupd1:4161', 'http://nsqlookupd2:4161']);

$callable = static function (Message $message): Generator {
    yield $message->touch(); // Reset the timeout for an in-flight message
    yield $message->requeue(timeout: 5000); // Re-queue a message (indicate failure to process)
    yield $message->finish(); // Finish a message (indicate successful processing)
};

$lookup->subscribe(topic: 'topic', channel: 'channel', onMessage: $callable);
$lookup->subscribe(topic: 'anotherTopic', channel: 'channel', onMessage: $callable);

$lookup->unsubscribe(topic: 'local', channel: 'channel');
$lookup->stop(); // unsubscribe all
```

### Integrations

[](#integrations)

- [Symfony](https://github.com/nsqphp/NsqBundle)

License:
--------

[](#license)

The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

884d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3bcbcfd167046c7e0620aa32e85d17bc3dbe043b5172f1f6e0e4d33b5effa41?d=identicon)[lishelun](/maintainers/lishelun)

---

Top Contributors

[![grachevko](https://avatars.githubusercontent.com/u/8628465?v=4)](https://github.com/grachevko "grachevko (144 commits)")[![lishelun](https://avatars.githubusercontent.com/u/13258880?v=4)](https://github.com/lishelun "lishelun (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lishelun-nsq/health.svg)

```
[![Health](https://phpackages.com/badges/lishelun-nsq/health.svg)](https://phpackages.com/packages/lishelun-nsq)
```

###  Alternatives

[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k132.9M468](/packages/zircote-swagger-php)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k314.0M3.4k](/packages/symfony-http-client)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[amphp/http-server

A non-blocking HTTP application server for PHP based on Amp.

1.3k4.5M81](/packages/amphp-http-server)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
