PHPackages                             sunsgne/webman-sms-send - 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. sunsgne/webman-sms-send

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

sunsgne/webman-sms-send
=======================

Webman plugin sunsgne/webman-sms-send

1.2.0(2y ago)090MITPHPPHP &gt;=8.1

Since Nov 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/sunsgneayo/webman-sms-send)[ Packagist](https://packagist.org/packages/sunsgne/webman-sms-send)[ RSS](/packages/sunsgne-webman-sms-send/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

 [![sunsgne](https://camo.githubusercontent.com/db2c48fed13718125a662dc35983cf565cd2281664e99d52cb24efcc8f3460a3/687474703a2f2f63646e2e6e696e65313132302e636e2f6c6f676f2d692e706e67)](https://camo.githubusercontent.com/db2c48fed13718125a662dc35983cf565cd2281664e99d52cb24efcc8f3460a3/687474703a2f2f63646e2e6e696e65313132302e636e2f6c6f676f2d692e706e67)

**sunsgne/webman-sms-send**

**🐬 Webman configuration system covering global SMS registration verification codes 🐬**

[![Latest Stable Version](https://camo.githubusercontent.com/c3b30d326502ee5625529e576da1f4e6629f7da9e6ff38595a92f010bead7cd3/687474703a2f2f706f7365722e707567782e6f72672f73756e73676e652f7765626d616e2d736d732d73656e642f76)](https://packagist.org/packages/sunsgne/webman-sms-send)[![Total Downloads](https://camo.githubusercontent.com/47242ea692984fac7623e2d8059bc1f7f1b12424ede82624a4efd49532e7be3b/687474703a2f2f706f7365722e707567782e6f72672f73756e73676e652f7765626d616e2d736d732d73656e642f646f776e6c6f616473)](https://packagist.org/packages/sunsgne/webman-sms-send)[![Latest Unstable Version](https://camo.githubusercontent.com/3252939bbb481647db93e2a5ceb1c9b6b6279ae2d2bd1fb5c1cfdbf2a837f464/687474703a2f2f706f7365722e707567782e6f72672f73756e73676e652f7765626d616e2d736d732d73656e642f762f756e737461626c65)](https://packagist.org/packages/sunsgne/webman-sms-send)[![License](https://camo.githubusercontent.com/b2ab7ad58d6686b0501d679b5f1d39198217e659ff42fe7bff9625612ea447b5/687474703a2f2f706f7365722e707567782e6f72672f73756e73676e652f7765626d616e2d736d732d73656e642f6c6963656e7365)](https://packagist.org/packages/sunsgne/webman-sms-send)[![PHP Version Require](https://camo.githubusercontent.com/dd9d3244a50d58d2ca998289e743f3b8889d985f78b3a7c3aa26ad37d36a72c5/687474703a2f2f706f7365722e707567782e6f72672f73756e73676e652f7765626d616e2d736d732d73656e642f726571756972652f706870)](https://packagist.org/packages/sunsgne/webman-sms-send)

Webman SMS Register
-------------------

[](#webman-sms-register)

### 功能特性

[](#功能特性)

- 简单快速的API，各模块可配置切支持扩展的引入
- 内置图形验证码，支持数字/字母/数学公式等验证方式
- 集成短信SMS发送请求
- 独立可移植的数据系统
- 完备短信模板管理，语言配置等后台管理API和面板

### 环境

[](#环境)

- PHP &gt;= 8.1.0
- workerman/webman-framework
- illuminate/database
- illuminate/redis

### 开始

[](#开始)

#### 安装/引入

[](#安装引入)

```
composer require sunsgne/webman-sms-send
```

#### 初始化数据表

[](#初始化数据表)

⚠️：请务必使用`illuminate/database`也就是`laravel`的数据库`orm`, 可参照[webman官方文档](https://www.workerman.net/doc/webman/db/tutorial.html);

```
./webman wsr-init-table
or
php webman wsr-init-table
```

#### 为国家/地区导入初始数据

[](#为国家地区导入初始数据)

```
./webman sync-country-data
or
php webman sync-country-data
```

#### 配置SMS云短信

[](#配置sms云短信)

以下是Tencent的短信参数示例

```
return [
    # 腾讯云-短信发送配置
    'tencent' => [
        'secretId'  => 'AKIDNaXEeoiLhma7NM4WhaDZeutb3E8l9G6e',
        'secretKey' => 'JL6anlSs1tUorMaXDcldEYbNt86nDMEq',
        'sdkAppId'  => '1400696413',
        'signName'  => 'BeiWorld',  //默认的短信签名
        'region'    => 'ap-guangzhou' // 默认的发送区域
    ]
];
```

文件位置：**/config/plugin/sunsgne/webman-sms-sms/sms.php**

#### 配置默认短信发送

[](#配置默认短信发送)

```
return [
    'enable' => true,

    'sms'     => [
        # 是否发送短信
        'sendSms'            => true,
        # 验证码长度
        'length'             => 4,
        # 根据以下字符生成验证码
        'rule'               => '0123456789',
        # 默认的短信过期时间
        'expiredTime'        => 5 * 60,
        # 是否使用默认模板
        'useDefaultTemp'     => true,
        # 默认的发送模板ID
        'defaultTempId'      => 1534804,
        # 默认的地区码
        'defaultCountryCode' => '86',

    ],
    'limitIp' => [
        # 是否开启ip发送次数验证
        'enable'     => true,
        # 验证周期（24小时不能超过maxSendNum）
        'duration'   => 60 * 60 * 24,
        # 周期内最大次数
        'maxSendNum' => 10
    ]
];
```

---

### SQL 相关表结构

[](#sql-相关表结构)

- **country\_code** （国际手机区域码配置表）

```
  CREATE TABLE `country_mobile` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `country_name_zh` varchar(255) NOT NULL COMMENT '国家中文名称（中国）',
  `country_name` json DEFAULT NULL COMMENT '国家名称;{"zh":"中国","en":"CHINA"}',
  `country_code` varchar(255) NOT NULL COMMENT '国家代号',
  `country_mobile_code` int NOT NULL COMMENT '国家/地区手机码',
  `regex` varchar(255) DEFAULT NULL COMMENT '手机号规则（正则表达式）',
  `national_flag` varchar(255) DEFAULT NULL COMMENT '国旗标识',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态（0：异常；1：正常；默认1）',
  `create_time` int DEFAULT NULL COMMENT '创建时间',
  `update_time` int DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `country_code_index` (`country_code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=191 DEFAULT CHARSET=utf8mb4 COMMENT='国际手机区域码配置表';
```

- **sms\_template** (短信模板配置表)

```
CREATE TABLE `sms_template` (
  `id` int NOT NULL AUTO_INCREMENT,
  `country_mobile_id` int NOT NULL COMMENT '关联country_mobile表中主键ID',
  `sms_service` varchar(255) NOT NULL COMMENT '短信服务商（tencent/alibaba）',
  `template_name` varchar(255) DEFAULT NULL COMMENT '短信模板名称',
  `template_id` int NOT NULL COMMENT '短信模板ID',
  `sms_type` varchar(255) DEFAULT NULL COMMENT '短信应用场景(register:注册；....)',
  `country_mobile_code` varchar(32) NOT NULL COMMENT '国家/地区手机码',
  `language` varchar(32) DEFAULT NULL COMMENT '短信语言（中文、英文）示例值:zh',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态（0：异常；1：正常；默认1）',
  `sms_content` varchar(255) DEFAULT NULL COMMENT '短信内容（验证码{1}，仅用于绑定手机，请勿告知他人，如有疑问请联系客服。）',
  `sms_sign` varchar(255) DEFAULT NULL COMMENT '短信签名（bei）',
  `app_package_name` varchar(128) DEFAULT NULL COMMENT '应用包名',
  `sms_expired_time` int DEFAULT NULL COMMENT '短信过期时长（单位：秒）',
  `create_time` int DEFAULT NULL COMMENT '创建时间',
  `update_time` int DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `c_s_t_index` (`country_mobile_id`,`sms_service`,`template_id`) USING BTREE,
  KEY `s_c_l_a_index` (`sms_type`,`country_mobile_code`,`language`,`app_package_name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT='国家/地区短信类型模板配置表';
```

- **mobile\_users** (手机号用户表)

```
CREATE TABLE `mobile_users` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int unsigned NOT NULL COMMENT '用户ID(与业务关联的唯一ID)',
  `country_mobile_code` int NOT NULL COMMENT '国家/地区手机区域码（86）',
  `mobile` varchar(64) NOT NULL COMMENT '手机号码(可加密)',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态（0：异常；1：正常；默认1）',
  `create_time` int DEFAULT NULL COMMENT '创建时间',
  `update_time` int DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_id_index` (`user_id`) USING BTREE COMMENT '用户唯一ID',
  KEY `mobile_index` (`mobile`) USING BTREE COMMENT '手机号'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='手机号用户表（webman-sms-register）';
```

- **sms\_send\_log** (sms短信发送记录表)

```
CREATE TABLE `sms_send_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `country_mobile_code` int NOT NULL,
  `mobile` varchar(32) NOT NULL,
  `scenes` varchar(64) DEFAULT NULL COMMENT '发送场景（register:注册....由客户端自定义）',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态（1:正常；0：异常）',
  `sms_service` varchar(64) DEFAULT NULL COMMENT '短信发送服务方',
  `sms_response` json DEFAULT NULL COMMENT '发送请求之后的响应',
  `create_time` int DEFAULT NULL COMMENT '创建时间',
  `update_time` int DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `c_m_s_index` (`country_mobile_code`,`mobile`,`scenes`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
```

---

### 短信服务（SMS）

[](#短信服务sms)

- 腾讯
- 阿里

### API

[](#api)

#### 国家/地区区域码列表

[](#国家地区区域码列表)

```
use Sunsgne\WebmanSmsSend\App;
App::GetCountryCodeList()
```

#### 国家/地区区域码列表(以国家编号作为KEY)

[](#国家地区区域码列表以国家编号作为key)

```
use Sunsgne\WebmanSmsSend\App;
App::GetCountryCodeAsKeyList()
```

返回的结构示例：

```
{
  "AD": {
    "country_mobile_code": 376,
    "country_name": {
      "en": "Andorra",
      "tw": "安道爾共和國",
      "zh": "安道尔共和国"
    },
    "country_name_zh": "安道尔共和国",
    "national_flag": "AD.png",
    "regex": ""
  }
}
```

#### 验证手机和国家编码合法

[](#验证手机和国家编码合法)

```
$status = App::VerifyLegalMobile('86' , '3255214');//bool
```

#### 发送手机验证码

[](#发送手机验证码)

```
use Sunsgne\WebmanSmsSend\App;
try {
    App::SendSmsCodeByTencent(
        mobileNum: '15998908728',
        countryCode: '86',
        clientIp: $request->getRealIp(false)
    );
} catch (\RedisException|SmsAppException $e) {
    dump($e->getMessage());
}
```

#### 验证手机短信验证码

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

```
use Sunsgne\WebmanSmsSend\App;
try {
    App::VerifyMobileCode(
        countryCode: '86',  // 国家地区编码
        mobileNum: '13012345678', //手机号码
        scenes: 'register', //发送场景
        vCode: '2154' // 验证码
    );
} catch (RedisException|SmsAppException $e) {
    //验证失败
}
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

4

Last Release

958d ago

### Community

Maintainers

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

---

Top Contributors

[![sunsgneayo](https://avatars.githubusercontent.com/u/51745500?v=4)](https://github.com/sunsgneayo "sunsgneayo (25 commits)")

### Embed Badge

![Health badge](/badges/sunsgne-webman-sms-send/health.svg)

```
[![Health](https://phpackages.com/badges/sunsgne-webman-sms-send/health.svg)](https://phpackages.com/packages/sunsgne-webman-sms-send)
```

PHPackages © 2026

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