PHPackages                             nyg/ali-mq - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. nyg/ali-mq

ActiveLibrary[Queues &amp; Workers](/categories/queues)

nyg/ali-mq
==========

0.0.1(5y ago)154MITPHPPHP &gt;=5.6

Since Aug 31Pushed 5y ago1 watchersCompare

[ Source](https://github.com/nyg123/ali-mq)[ Packagist](https://packagist.org/packages/nyg/ali-mq)[ RSS](/packages/nyg-ali-mq/feed)WikiDiscussions master Synced 5d ago

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

阿里云RocketMQ
-----------

[](#阿里云rocketmq)

#### 1,发布普通消息

[](#1发布普通消息)

```
$config = [
        'http_endpoint' => 'http://101840946123456.mqrest.cn-qingdao.aliyuncs.com', //HTTP接入域名
        'access_key' => 'LTAI4GG1oUUfffwettqmy2Z2', //AccessKey 阿里云身份验证，在阿里云服务器管理控制台创建
        'secret_key' => '6jYo9yuEtertertdfgre8rR432xCl3Vl',  // SecretKey 阿里云身份验证，在阿里云服务器管理控制台创建
        'topic' => 'test_topic', //主题
        'instance_id' => 'MQ_INST_1018409462019097_BXReEF0c', //实例ID
    ];
$data=['a' => 1, 'b' => 2]; //需要发布的数据
$tag='abc'; //消息标签，二级消息类型，用来进一步区分某个 Topic 下的消息分类

try {
    MQ::producer($this->config)->push($data, 'abc'); //推送数据，成功返回MessagePropertiesForPublish类
} catch (Exception $e) {
    //发送失败
}
```

#### 2，订阅普通消息

[](#2订阅普通消息)

```
$config = [
        'http_endpoint' => 'http://101840946123456.mqrest.cn-qingdao.aliyuncs.com', //HTTP接入域名
        'access_key' => 'LTAI4GG1oUUfffwettqmy2Z2', //AccessKey 阿里云身份验证，在阿里云服务器管理控制台创建
        'secret_key' => '6jYo9yuEtertertdfgre8rR432xCl3Vl',  // SecretKey 阿里云身份验证，在阿里云服务器管理控制台创建
        'topic' => 'test_topic', //主题
        'instance_id' => 'MQ_INST_1018409462019097_BXReEF0c', //实例ID
    ];
$tag = 'abc';
$consumer=MQ::consumer($config,$tag);
while (true){
$result = $consumer->run(3,10); //设置一次最多消费3条，最多等待10秒
if(empty($result)){ //10秒内没有数据，继续运行
    continue;
}
$this->assertNotEmpty($result);
    foreach ($result as $v) {
        $data =json_decode($v->getMessageBody(),true);
        //在这里处理数据，处理成功后需要调用ask
        $ask=$consumer->ask($v->getReceiptHandle());

    }
}
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

2084d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/034ee0bcfafe1b9e0d463b779f1fcc2177a5f651ce370b5d3686c13304281224?d=identicon)[牛永光](/maintainers/%E7%89%9B%E6%B0%B8%E5%85%89)

---

Top Contributors

[![nyg123](https://avatars.githubusercontent.com/u/30823967?v=4)](https://github.com/nyg123 "nyg123 (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nyg-ali-mq/health.svg)

```
[![Health](https://phpackages.com/badges/nyg-ali-mq/health.svg)](https://phpackages.com/packages/nyg-ali-mq)
```

PHPackages © 2026

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