PHPackages                             zfegg/sms-sender - 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. zfegg/sms-sender

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

zfegg/sms-sender
================

SMS sender service. And use for send sms captcha handler / 短信发送模块, 并且用于发送短信验证码处理程序

2.1.0(3y ago)41664MITPHPPHP &gt;=7.3CI failing

Since Aug 9Pushed 3y ago2 watchersCompare

[ Source](https://github.com/zfegg/sms-sender)[ Packagist](https://packagist.org/packages/zfegg/sms-sender)[ RSS](/packages/zfegg-sms-sender/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (14)Versions (8)Used By (0)

短信发送抽象接口
========

[](#短信发送抽象接口)

[![GitHub Actions: Run tests](https://github.com/zfegg/sms-sender/workflows/qa/badge.svg)](https://github.com/zfegg/sms-sender/actions?query=workflow%3A%22qa%22)[![Coverage Status](https://camo.githubusercontent.com/8465697631a27e50d08e2bbe4d197f25467c30d5ee6d50fc4ba4a9b0a70f5781/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7a666567672f736d732d73656e6465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/zfegg/sms-sender?branch=master)[![Coverage Status](https://camo.githubusercontent.com/8465697631a27e50d08e2bbe4d197f25467c30d5ee6d50fc4ba4a9b0a70f5781/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7a666567672f736d732d73656e6465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/zfegg/sms-sender?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/db182bb7404d53cb2dd7cb57c6f7f8ee9f71b2f32816ce1cafbcdff5b5ecbd9c/687474703a2f2f706f7365722e707567782e6f72672f7a666567672f736d732d73656e6465722f76)](https://packagist.org/packages/zfegg/sms-sender)[![Total Downloads](https://camo.githubusercontent.com/e586d3cdaa03949149bdb676fdda6dc333d154beb0e23b337afaadf61c46195d/687474703a2f2f706f7365722e707567782e6f72672f7a666567672f736d732d73656e6465722f646f776e6c6f616473)](https://packagist.org/packages/zfegg/sms-sender)[![License](https://camo.githubusercontent.com/a6fdaaecfad354dfa4f431d10008db8c9f4d1d1d129da24d9807f002977a9a8e/687474703a2f2f706f7365722e707567782e6f72672f7a666567672f736d732d73656e6465722f6c6963656e7365)](https://packagist.org/packages/zfegg/sms-sender)[![PHP Version Require](https://camo.githubusercontent.com/d3c4ec79d72c8a9a6dc36c6cdc65f755f15fe88a94549ec94598b5f75b6bd375/687474703a2f2f706f7365722e707567782e6f72672f7a666567672f736d732d73656e6465722f726571756972652f706870)](https://packagist.org/packages/zfegg/sms-sender)

抽象常用短信业务:

1. 实现短信的限制发送（60s 内限制发送1次，1天上限发送10次）
2. 短信验证码生成与验证功能

Installation / 安装
-----------------

[](#installation--安装)

使用 Composer 安装

```
$ composer require zfegg/sms-sender

```

Interfaces / 接口说明
-----------------

[](#interfaces--接口说明)

- `Zfegg/SmsSender/Provider/ProviderInterface` 短信供应商实现接口

Usage / 使用
----------

[](#usage--使用)

### 基本使用示例代码：

[](#基本使用示例代码)

[示例代码](examples/basic.php)

### 在 Expressive 中使用：

[](#在-expressive-中使用)

在 `config/application.php` 中添加模块加载.

```
return array(
    'modules' => array(
        //... Your modules
        'Zfegg/SmsSender'
    ),
);
```

添加短信发送配置 `module.config.php`

```
return [
    'dependencies' => [
        'factories' => [
            ProviderInterface::class => YourSmsProviderFactory::class,
        ],
    ]
    'zfegg' => [
        LimitSender::class => [
            'provider' => ProviderInterface::class, // 设置短信商服务名. (可选), 默认 `ProviderInterface::class`
            'cache' => CacheInterface::class, // 设置缓存服务名 (可选), 默认 `CacheInterface::class`
            'day_send_times' => 10, // 设置每天发送次数上限 (可选), 默认10
            'waiting_time' => 60, //设置每次发送等待时长 (可选), 默认60s
        ],
        PostSmsCaptchaHandler::class  => [
            'types' => [
               'register' => 'Register captcha code: {code}',
               'login' => 'Login captcha code: {code}',
            ]
        ],
    ]
];
```

控制器使用：

```
//发送验证码
$app->post('/api/send-sms-captcha', PostSmsCaptchaHandler::class);

//业务验证码验证
$app->post('/register', [
  function ($req, $handler) {

    //配置验证器
    $inputFilter = (new \Laminas\InputFilter\Factory)->create([
        [
            'name' => 'captcha',
            'validators' => [
                [
                    'name' => SmsCode::class,
                    'options' => [
                        'inputName' => 'phone',
                    ]
                ]
            ]
        ],
        [
            'name' => 'phone',
            'validators' => [
                [
                    'name' => 'PhoneNumber',
                ]
            ]
        ],
    ])

    if (! $inputFilter->isValid()) {
        //验证失败响应
        return new JsonResponse(['messages' => $inputFilter->getMessages()], 403);
    }

    //验证成功继续注册
    return $handler->handle($req);
  },
  YourRegisterHandler::class,
])
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 97.5% 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 ~452 days

Recently: every ~553 days

Total

6

Last Release

1346d ago

Major Versions

1.1.2 → 2.0.02020-01-13

PHP version history (3 changes)1.0.0PHP ^5.5 || ^7.0

2.0.0PHP ^7.2

2.1.0PHP &gt;=7.3

### Community

Maintainers

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

---

Top Contributors

[![Moln](https://avatars.githubusercontent.com/u/2050694?v=4)](https://github.com/Moln "Moln (39 commits)")[![xuman3288](https://avatars.githubusercontent.com/u/3776243?v=4)](https://github.com/xuman3288 "xuman3288 (1 commits)")

---

Tags

smssmscaptchahandlerSendersms senderzfegg

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/zfegg-sms-sender/health.svg)

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[phpro/soap-client

A general purpose SoapClient library

8895.9M52](/packages/phpro-soap-client)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M524](/packages/shopware-core)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

1237.8M121](/packages/web-auth-webauthn-lib)

PHPackages © 2026

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