PHPackages                             wuzhengyu0748/squeue - 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. wuzhengyu0748/squeue

ActiveProject

wuzhengyu0748/squeue
====================

php-delay-message-queue

v1.1(5y ago)012MITPHPPHP &gt;=7.0.0

Since May 15Pushed 5y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (0)

squeue
======

[](#squeue)

依赖
--

[](#依赖)

- swoole &gt;= 4.4
- php &gt;= 7.1

安装
--

[](#安装)

```
composer require wuzhengyu0748/squeue

```

代码示例
----

[](#代码示例)

### 启动服务

[](#启动服务)

```
// 实例化Squeue对象，参数传入 redis的ip和端口号，第三个参数密码可选
$mq = new \Squeue\Squeue('127.0.0.1', 6379, $passwd);

// 调用start函数启动队列服务
$mq->start();

```

以上代码使用php-cli模式运行即可，建议配合 supervisor 监控和管理进程

### 添加一个消息任务

[](#添加一个消息任务)

```
// 实例化对象
$mq = new \Squeue\Squeue('127.0.0.1', 6379);

// 事件类型
$topic = 'orderSubmit';

// 消息内容
$body = [
    'orderId' => '1001',
    'price' => '222'
];

// 加入对列 返回值为 jobID
$jobId = $mq->add($topic, $body);

```

以上代码的 add 方法有四个参数 可选的三个参数传入一个秒数，代表延迟多少秒后再执行。 第四个参数也是传入秒数，代表如果任务失败或超时延迟多久重试。

### 消费队列

[](#消费队列)

```
// 实例化对象
$mq = new \Squeue\Squeue('127.0.0.1', 6379);

// 事件类型
$topic = 'orderSubmit';

while (true) {

    // 从队列取出该事件类型的一个消息
    $job = $mq->pop($topic);

    // 执行相应的业务逻辑。。。。

    // 任务执行完毕后 调用finish 告知 squeue 队列被正常消费，否则squeue将根据add设置的TTR（默认60秒）的时间间隔重试，直到消息被正常应答
    $mq->finish($job->jobId);

    usleep(1000);
}

```

### 删除某个消息

[](#删除某个消息)

```
// 实例化对象
$mq = new \Squeue\Squeue('127.0.0.1', 6379);

// 任务被删除后立即生效，即使已经在队列也会被删除
$mq->delete($jobId);

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

2186d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d6e0ebb54572b4b8c33f4cf7e1e8fe3852e9490b081d8570da2afd212d4dfa9?d=identicon)[wuzhengyu0748](/maintainers/wuzhengyu0748)

---

Top Contributors

[![wuzhengyu0748](https://avatars.githubusercontent.com/u/22119961?v=4)](https://github.com/wuzhengyu0748 "wuzhengyu0748 (11 commits)")

### Embed Badge

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

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

PHPackages © 2026

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