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)0419MITPHPPHP ^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 today

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 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

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

933d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13258880?v=4)[Lee](/maintainers/lishelun)[@lishelun](https://github.com/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

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k869.4M8.8k](/packages/symfony-http-kernel)[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[amphp/http-server

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

1.3k6.7M110](/packages/amphp-http-server)

PHPackages © 2026

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