PHPackages                             mitsuha/sms-pusher - 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. mitsuha/sms-pusher

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

mitsuha/sms-pusher
==================

An expandable SMS verification code expansion package

v0.1(5y ago)65MITPHPPHP ^7.0

Since Oct 31Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Mitsuha/SmsPusher)[ Packagist](https://packagist.org/packages/mitsuha/sms-pusher)[ RSS](/packages/mitsuha-sms-pusher/feed)WikiDiscussions master Synced 1mo ago

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

高扩展性的短信验证码扩展包
=============

[](#高扩展性的短信验证码扩展包)

安装
--

[](#安装)

使用 composer 安装包：

```
composer require mitsuha/sms-pusher

```

发布资源组

```
php artisan vendor:publish --tag=config
```

使用
--

[](#使用)

提供了一个控制器来获取验证码，路由可在配置文件中的 `route-prefix` 中修改，控制器获取手机号的字段可以在 `inputKey` 中修改

提供了 `sms` 验证规则，在需要短信验证的字段添加后，请求时需多带一个 `{$attribute}Code`， 如：

```
$request->validate([
    'telephone' => ['required', 'sms']
]);
```

请求时：

```
application/json
{
    "telephone": "1-503-962-3772",
    "telephoneCode": "35614"
}
```

如验证码正确，请求将通过。否则会抛出一个表单异常

配置
--

[](#配置)

SmsPusher 分为两部分： 一个是 Driver 负责存储和校验验证码，另一个 Pusher 负责处理发信请求。扩展包中定义了两个 Contracts 分别对应两部分的业务实现

- 自定义储存和校验逻辑请实现 `mitsuha\SmsPusher\Driver\DriverContracts`
- 自定义发信请求请实现 `mitsuha\SmsPusher\Sms\SmsPusherContracts`

之后在配置文件 `sms.php` 中添加对应的实现，然后修改 `default` 使其生效

```
'driver' => [
    'default' => 'example',
    'implement' => [
       'redis' => \mitsuha\SmsPusher\Driver\RedisDriver::class,
       'hash' => \mitsuha\SmsPusher\Driver\HashDriver::class,
       'example' => \App\Http\Realization\ExampleDriver::class,
    ]
]

```

大多数情况下，验证码存储和校验都有通用的解决方案，但短信服务商多种多样，其提供的 API 也一言难尽。与其去支持各种服务商，不如把校验和存储的部分实现，具体的发信行为交由用户

实现一个发信请求，SmsPusher 需要你实现 `mitsuha\SmsPusher\Sms\SmsPusherContracts` 接口：

```
// 向指定的手机号，发送指定内容的短信
public function push($telephone, $content): void ;

// 短息发送是否成功
public function success(): bool ;

// 不成功时的错误信息
public function message(): string ;

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

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

2024d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f017f48c1d7edf1c36c918ae9c41febd44addd951eca51f89864c506f5571ce?d=identicon)[Mitsuha](/maintainers/Mitsuha)

---

Top Contributors

[![Mitsuha](https://avatars.githubusercontent.com/u/30211094?v=4)](https://github.com/Mitsuha "Mitsuha (9 commits)")

---

Tags

laravel-smslaravel SMS verification code

### Embed Badge

![Health badge](/badges/mitsuha-sms-pusher/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)

PHPackages © 2026

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