PHPackages                             huilin/rocketmq-client-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. huilin/rocketmq-client-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

huilin/rocketmq-client-php
==========================

rocketmq-client-php

05C++

Since Oct 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/SiZhe/rocketmq-client-php)[ Packagist](https://packagist.org/packages/huilin/rocketmq-client-php)[ RSS](/packages/huilin-rocketmq-client-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

rocketmq-client-php
===================

[](#rocketmq-client-php)

A Php Client for Apache RocketMQ. 【有问题可以加微信 **f124816** 反馈,备注RocketMQ Php Client】

dependence
==========

[](#dependence)

- [rocketmq-client-cpp](https://github.com/apache/rocketmq-client-cpp)
- [PHP-CPP](https://github.com/CopernicaMarketingSoftware/PHP-CPP)
- php7

INSTALL
-------

[](#install)

1. install rocketmq-client-cpp; (dist/Dockerfile is a example to build a librocketmq.so file)
2. do shell:

```
    cp bin/librocketmq.so /usr/lib/;
    mkdir /usr/include/rocketmq/ ;
    cp include/* /usr/include/rocketmq/

```

3. install php-cpp
4. download rocketmq-client-php

```
    git clone https://github.com/lpflpf/rocketmq-client-php;
    cd rocketmq-client-php;
    make && make install
```

5. update php.ini file, add line `extension=rocketmq.so`;
6. try to run example in example directory.

Usage
-----

[](#usage)

to see autocompelete file.

Example
-------

[](#example)

### Producer Example

[](#producer-example)

```
namespace RocketMQ;
$instanceName = "MessageQueue";

$producer = new Producer($instanceName);
$producer->setInstanceName($instanceName);
$producer->setNamesrvAddr("127.0.0.1:9876");
$producer->start();

for ($i = 0; $i < 10000; $i ++){
    $message = new Message("TopicTest", "*", "hello world $i");
    $sendResult = $producer->send($message);
    echo $sendResult->getSendStatus() . "\n";
}
```

### PullConsumer Example

[](#pullconsumer-example)

It is a good idea to save offset in local.

```
namespace RocketMQ;

$consumer = new PullConsumer("pullTestGroup");
$consumer->setInstanceName("testGroup");
$consumer->setTopic("TopicTest");
$consumer->setNamesrvAddr("127.0.0.1:9876");
$consumer->start();
$queues = $consumer->getQueues();

foreach($queues as $queue){
    $newMsg = true;
    $offset = 0;
    while($newMsg){
        $pullResult = $consumer->pull($queue, "*", $offset, 8);

        switch ($pullResult->getPullStatus()){
        case PullStatus::FOUND:
            foreach($pullResult as $key => $val){
                echo $val->getMessage()->getBody() . "\n";
            }
            $offset += count($pullResult);
            break;
        default:
            $newMsg = false;
            break;
        }
    }
}
```

### PushConsumer Example

[](#pushconsumer-example)

```
namespace RocketMQ;

$consumer = new PushConsumer("testGroup");
$consumer->setInstanceName("testGroup");
$consumer->setNamesrvAddr("127.0.0.1:9876");
$consumer->setThreadCount(10);
$consumer->setListenerType(MessageListenerType::LISTENER_ORDERLY);
$count = 0;
$consumer->setCallback(function ($msg) use (&$count){
    echo $msg->getMessage()->getBody() . "\n";
    $count ++;
});
$consumer->subscribe("TopicTest", "*");
$consumer->start();
$consumer->shutdown();
```

Docker
------

[](#docker)

1. Build rocketmq-client-cpp Container.

```
cd dist
docker build -t rocketmq-client-cpp:1.2.2 ./dist

```

2. Build rocketmq-client-php Container

```
docker build -t rocketmq-client-php:1.0.0 .

```

TODO
----

[](#todo)

1. Manual commit an offset.
2. Log handle. ( specify log file is no support by rocketmq-client-cpp. )
3. Doc.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

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

---

Top Contributors

[![lpflpf](https://avatars.githubusercontent.com/u/11867562?v=4)](https://github.com/lpflpf "lpflpf (116 commits)")[![osgochina](https://avatars.githubusercontent.com/u/1379073?v=4)](https://github.com/osgochina "osgochina (1 commits)")

### Embed Badge

![Health badge](/badges/huilin-rocketmq-client-php/health.svg)

```
[![Health](https://phpackages.com/badges/huilin-rocketmq-client-php/health.svg)](https://phpackages.com/packages/huilin-rocketmq-client-php)
```

###  Alternatives

[vpietri/adm-quickdevbar

QuickDevBar is a developer toolbar for magento 2

577348.6k](/packages/vpietri-adm-quickdevbar)[minime/annotations

The KISS PHP annotations library

229378.6k36](/packages/minime-annotations)[data-uri/data-uri

PHP DataURI component

60627.5k4](/packages/data-uri-data-uri)[friendsoftypo3/frontend-editing

Enable editors to work with the content in the most intuitive way possible

110123.8k2](/packages/friendsoftypo3-frontend-editing)[rockettheme/toolbox

RocketTheme Toolbox Library

22526.9k3](/packages/rockettheme-toolbox)[holiday-jp/holiday_jp

Japanese holidays

20161.3k](/packages/holiday-jp-holiday-jp)

PHPackages © 2026

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