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

ActiveLibrary

viliy/sms
=========

SMS for PHP

v1.1.3(7y ago)193MITPHPPHP &gt;=7.0

Since Apr 17Pushed 7y agoCompare

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

READMEChangelog (9)Dependencies (3)Versions (16)Used By (0)

sms
===

[](#sms)

平台支持
----

[](#平台支持)

- [阿里大于](https://www.alidayu.com/)
- [SendCloud](http://www.sendcloud.net/)
- [253云通讯（创蓝）](https://www.253.com/)
- [秒嘀科技](http://www.miaodiyun.com/)
- [未来无线](http://www.10690757.com)
- [掌骏传媒](http://www.zjunmedia.cn)
- [Nexmo](https://developer.nexmo.com)

环境需求
----

[](#环境需求)

- PHP &gt;= 7.0

安装
--

[](#安装)

```
$ composer require "viliy/sms"
```

使用
--

[](#使用)

```
use Viliy\SMS\Sender;

require __DIR__ . '/vendor/autoload.php';

/**
 * 平台网关配置
 */

$gateways = [
    'alidayu' => [
        'app_key' => '*****',
        'app_secret' => '*******',
        'signature' => '签名',
        'weight' => 10,  // 渠道比重  排序算法时使用 可不传 in:1,100
    ],
    'sendcloud' => [
        'sms_user' => '*****',
        'sms_key' => '**********',
        'signature' => '签名',
        'weight' => 20,
    ],
    'weilaiwuxian' => [
        'cust_code' => '******',
        'password' => '*************',
        'signature' => '签名',
        'weight' => 10,

    ],
    'junmei' => [
        'account' => '******',
        'user_id' => '*************',
        'password' => '*************',
        'signature' => '签名',
        'weight' => 10,

    ],
    'miaodi' => [
        'account_sid' => '*******',
        'auth_token' => '**************',
        'signature' => '签名',
        'weight' => 10,

    ],
    'chuanglan' => [
        'account' => '******',
        'password' => '*************',
        'signature' => '签名',
        'weight' => 10,
    ],
    'nexmo' => [
        'api_key' => '******',
        'api_secret' => '******',
        'from' => 'NEXMO', // 官网这个值并没有要求
        'signature' => '签名',
    ]
];

/**
 * 短信配置
 * 为了兼容多个发送平台 message需要包含以下信息
 */
$message = [
    'identifier' => '短信模板',   // 平台短信模板
    'content' => '尊敬的用户,您的短信验证码为：{code}',  // 短信模板
    'data' => [  // 参数 对应content 变量
        'code' => 12344,
    ],
    'type' => 'text'
];

/**
 * 使用
 */
try {
    $sender = new Sender('weight', $gateways); // 初始化发送实例， 提供三个排序算法: order 顺序发送，random 随机发送， weight 权重发送， 默认order

    $result = $sender->send('15018093840', $message);

} catch (\Viliy\SMS\Exceptions\InvalidArgumentException $e) {

    var_dump($e->getMessage());
} catch (\Viliy\SMS\Exceptions\NoGatewayAvailableException $e) {
    var_dump($e->getMessage());
}

// or
try {
    $sender = new Sender('weight');

    $result = $sender->send('15018093840', $message, $gateways);  // 可以发送时指定网关

} catch (\Viliy\SMS\Exceptions\InvalidArgumentException $e) {

    var_dump($e->getMessage());
} catch (\Viliy\SMS\Exceptions\NoGatewayAvailableException $e) {
    var_dump($e->getMessage());
}

var_dump($result);

## 返回值

由于使用多网关发送，所以返回值为一个数组，结构如下：
```php
[
    'chuanglan' => [
        'status' => 'success',
        'result' => [...] // 平台返回值
    ],
    'aliyun' => [
        'status' => 'failure',
        'result' => [...] // 捕获的错误信息
    ],
    //...
]
```

todo
----

[](#todo)

错误信息的格式化和处理

回调查看短信是否发送成功（判断第三方是否发送成功）

License
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

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

Total

14

Last Release

2746d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f14694b4665d82d319b5a9321824d9b23174039ec67fa44098b64e9d32e7cf0?d=identicon)[viliy](/maintainers/viliy)

---

Top Contributors

[![viliy](https://avatars.githubusercontent.com/u/22161786?v=4)](https://github.com/viliy "viliy (2 commits)")

---

Tags

phpsmsFastDsms library

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[toplan/phpsms

Probably the most intelligent, elegant sms send library in php

638115.9k5](/packages/toplan-phpsms)[djunehor/laravel-sms

Send SMS from your laravel application

385.3k1](/packages/djunehor-laravel-sms)[amirbagh75/smsir-php

Unofficial sms.ir PHP Package

181.2k](/packages/amirbagh75-smsir-php)

PHPackages © 2026

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