PHPackages                             ddsm2016/sv - 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. ddsm2016/sv

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

ddsm2016/sv
===========

短信验证码发送验证类

1.1.1(10y ago)029MITPHP &gt;=5.5.9

Since Jun 26Compare

[ Source](https://github.com/ddsm2016/sv)[ Packagist](https://packagist.org/packages/ddsm2016/sv)[ Docs](https://github.com/ddsm2016/sv/wiki)[ RSS](/packages/ddsm2016-sv/feed)WikiDiscussions Synced 2w ago

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

短信验证码类
======

[](#短信验证码类)

> 通过Composer `ddsm2016/sv` 包可以获取该类库

依赖模块/类库
-------

[](#依赖模块类库)

1. 该类依赖ddsm2016/ddsm类库包，以提供短信发送服务
2. 该类依赖特定结构的Eloquent模型，用于保存验证码相关状态信息

Eloquent模型表结构
-------------

[](#eloquent模型表结构)

序号字段名中文名类型及长度备注1idIDvarchar(255)主键2code验证码varchar(8)验证码 最多长度8位3dayget当天已获取次数tinyint无符号4verifyed此验证码已验证次数tinyint无符号5created\_at验证码创建时间datetime-6updated\_at验证码记录更新时间datetime-**说明**

- ID用于标识某条特定的短信验证码记录

**Laravel Migration字段定义**

```
$table->string('id');
$table->string('code', 8);
$table->tinyInteger('dayget', false, true)->default(1);
$table->tinyInteger('verifyed', false, true)->default(0);
$table->timestamps();
// 主键定义
$table->primary('id');
```

初始化配置项
------

[](#初始化配置项)

```
$config = [
	'expire_time' => 1800,  // 验证码有效期（秒）
	'get_max'     => 3, // 每天最多可获取验证码次数
	'verify_max'  => 3, // 每条验证码最大可试错次数
];
```

初始化类实例
------

[](#初始化类实例)

```
$sv = SmsVerify::instance($id);  // 设置验证码记录ID，返回当前对象$this

$sv->config($config); // 设置配置项，返回当前对象$this

$sv->model($model);  // $model为短信验证码Eloquent模型，返回当前对象$this
```

方法清单
----

[](#方法清单)

- 发送短信验证码 send($phone)
- 短信验证码验证 verify($inputCode)
- 获取最后产生错误信息 error()

### 发送短信验证码

[](#发送短信验证码)

```
/**
 * 发送短信验证码
 * @param string $phone 接收验证码手机号码
 * @return bool
 */
$sv->sms($sms)->content($template)->send($phone);
```

> - 如果验证码发送失败，可通过`$sv->error()`获取错误信息
> - `sms`方法用于设定短信发送类实例
> - `content`方法用于订制验证码短信模板，%s表示验证码占位符

### 短信验证码验证

[](#短信验证码验证)

```
/**
 * 短信验证码验证
 * @param string $inputCode 粉丝输入待验证的验证码
 * @return bool
 */
$sv->verify($inputCode);
```

> 如果验证码验证失败，可通过$sv-&gt;error()获取错误信息

### 获取最后产生错误信息

[](#获取最后产生错误信息)

```
$sv->error();  // 用于获取最后一次产生的错误信息
```

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

3

Last Release

3699d ago

### Community

Maintainers

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

---

Top Contributors

[![pwf0112](https://avatars.githubusercontent.com/u/6256668?v=4)](https://github.com/pwf0112 "pwf0112 (8 commits)")

### Embed Badge

![Health badge](/badges/ddsm2016-sv/health.svg)

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

###  Alternatives

[sebastiaanluca/php-pipe-operator

Method chaining (or fluent expressions) for any value using any method.

288470.0k2](/packages/sebastiaanluca-php-pipe-operator)[padam87/bin-packer

2D bin packing for PHP

249.2k](/packages/padam87-bin-packer)

PHPackages © 2026

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