PHPackages                             filix/sms\_queue - 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. filix/sms\_queue

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

filix/sms\_queue
================

Send SMS with Queue

183PHP

Since Apr 1Pushed 12y ago2 watchersCompare

[ Source](https://github.com/filix/sms_queue)[ Packagist](https://packagist.org/packages/filix/sms_queue)[ RSS](/packages/filix-sms-queue/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

\#SMS QUEUE

\##简介

通过队列的方式发送短信，暂时实现了redis作为队列。

以实现的第三方短信服务： [百悟](http://www.baiwutong.com/)、[漫道](http://www.zucp.net)。

发送短信方，只需要将短信丢进队列。队列分主、副两个队列。
优先选择丢进住队列，在丢进住队列前，判断若主队列消息堆积，则丢进副队列。

两个队列对应两个消费者：主消费者和副消费者。

主消费者从主队列获取消息，尝试发送，若失败则丢进副队列，有副队列负责发送。

\##使用方式

\###创建消息、消息入队列

```
use Filix\SMS\Queue\RedisQueue;
use Filix\SMS\Message\Message;
use Filix\SMS\Producer\PrimaryProducer;
use Filix\SMS\SmsService\BWService;

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
//主队列
$primaryQueue = new RedisQueue($redis, 'PRIMARY_CHANNEL');
//副队列
$secondaryQueue = new RedisQueue($redis, 'SECONDARY_CHANNEL');

//创建sms
$message = new Message();
$message->setMobiles(array('13512345678', '13412345678'));
$message->setContent('Hello!');

//将百悟作为主服务
$service = new BWService($corp_id, $corp_pwd, $corp_service);
//主生产者
$producer = new PrimaryProducer($service, $primaryQueue, $secondaryQueue);
//其实只是丢进主队列或副队列（主队列堆积时），并没有真正的发送
$producer->send($message);
```

\###发送消息

创建主消费者脚本：

```
use Filix\SMS\Queue\RedisQueue;
use Filix\SMS\Customer\PrimaryCustomer;
use Filix\SMS\SmsService\BWService;

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$primaryQueue = new RedisQueue($redis, 'PRIMARY_CHANNEL');
$secondaryQueue = new RedisQueue($redis, 'SECONDARY_CHANNEL');
$service = new BWService($corp_id, $corp_pwd, $corp_service);
$customer = new PrimaryCustomer($service, $primaryQueue, $secondaryQueue);

while(1){
    $result = $customer->fetchAndSend(3); //一次获取3条消息，并发地向服务商接口发送
    sleep(1);
}
```

\##自定义

\###自定义queue

实现Filix\\Queue\\QueueInterface接口即可，如实现自己的Mysql队列、RabbitMQ队列等。

\###自定义第三方短信服务商

实现Filix\\SmsService\\ServiceInterface接口即可。

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2655567?v=4)[Filix](/maintainers/Filix)[@Filix](https://github.com/Filix)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/filix-sms-queue/health.svg)

```
[![Health](https://phpackages.com/badges/filix-sms-queue/health.svg)](https://phpackages.com/packages/filix-sms-queue)
```

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.5M30](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6045.5M508](/packages/illuminate-bus)[uecode/qpush-bundle

Asynchronous processing for Symfony using Push Queues

1672.5M2](/packages/uecode-qpush-bundle)[jayazhao/think-queue-rabbitmq

为 ThinkPHP5.1 队列增加 RabbitMQ 驱动

141.5k](/packages/jayazhao-think-queue-rabbitmq)[mayconbordin/l5-stomp-queue

Stomp Queue Driver for Laravel 5

121.1k](/packages/mayconbordin-l5-stomp-queue)

PHPackages © 2026

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