PHPackages                             nsq/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. nsq/nsq

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

nsq/nsq
=======

NSQ Client for PHP

0.9.1(3y ago)3645.5k↓11.5%5[1 issues](https://github.com/nsqphp/nsqphp/issues)3MITPHPPHP ^8.1

Since Jan 19Pushed 3y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (16)Versions (18)Used By (3)

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

37

—

LowBetter than 81% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~37 days

Recently: every ~107 days

Total

17

Last Release

1391d ago

PHP version history (3 changes)0.1PHP &gt;=7.4

0.4PHP ^8.0.1

0.9.1PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8628465?v=4)[Konstantin Grachev](/maintainers/grachevko)[@grachevko](https://github.com/grachevko)

---

Top Contributors

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

---

Tags

nsqnsq-clientnsqphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/nsq-nsq/health.svg)](https://phpackages.com/packages/nsq-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)
