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

ActiveLibrary

seffeng/sms
===========

PHP extension sms

v1.0.4(4y ago)03.2k↓100%1MITPHPPHP &gt;=7.1.3

Since Nov 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/seffeng/sms)[ Packagist](https://packagist.org/packages/seffeng/sms)[ Docs](https://github.com/seffeng/sms)[ RSS](/packages/seffeng-sms/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (2)Versions (7)Used By (1)

SmsClient
---------

[](#smsclient)

### 安装

[](#安装)

```
# 暂时支持 阿里云 和 腾讯云 发送短信
$ composer require seffeng/sms

```

### 目录说明

[](#目录说明)

```
│ SmsClient.php                 基类
├─Clients
│  ├─Aliyun                     阿里云
│  │      Client.php                阿里云发送处理类
│  │      Error.php                 阿里云错误
│  │      TemplateParams.php        短信内容参数对应
│  └─Qcloud                     腾讯云
│          Client.php               腾讯云发送处理类
│          Error.php                腾讯云错误
├─Exceptions
│      SmsException.php             异常基类
└─Helpers
       ArrayHelper.php              数组帮助类

```

### 示例

[](#示例)

```
/**
 * SiteController
 */
use Seffeng\Sms\SmsClient;
use Seffeng\Sms\Exceptions\SmsException;

class SiteController extends Controller
{
    public function index()
    {
        try {
            $sdkAppId = '';             // 腾讯云SDKAppID  阿里云不需要
            $appSecretId = '';          // 腾讯云SecretId 或 阿里云 AccessKeyId
            $appSecretKey = '';         // 腾讯云SecretKey 或 阿里云 AccessKeySecret
            $name = 'aliyun';           // qcloud 或 aliyun
            $signName = '签名';         // 签名内容
            $tempCode = 'SMS_153055065'; // 腾讯云 templateId[1234] 或 阿里云 TemplateCode[SMS_153055065]
            $content = ['111111'];      // 腾讯云 ['111111'] 或 阿里云 ['code' => '111111']
            $phone = '13800138000';     // 相同内容可批量发送['13800138000', '13800138001']

            // 因阿里云与腾讯云的内容参数结构不一致，参考 $content；可通过 TemplateParams 实现以腾讯云结构发送
            $templateParamsModel = new TemplateParams();
            $client = new SmsClient($appSecretId, $appSecretKey, $sdkAppId);
            $result = $client->setClient($name, $templateParamsModel)
                        ->setSignName($signName)
                        ->setTemplateCode($tempCode)
                        ->send($phone, $content);

            if ($result) {
                echo '发送成功！';
            } else {
                echo '发送失败！';
            }
        } catch (SmsException $e) {
            echo $e->getMessage();
        } catch (\Exception $e) {
            echo $e->getMessage();
        }
    }
}
```

```
/**
 * TemplateParams
 * @see Seffeng\Sms\Clients\Aliyun\TemplateParams
 */
class TemplateParams extends \Seffeng\Sms\Clients\Aliyun\TemplateParams
{
    /**
     * 重写模板对应参数
     * @return array
     */
    public static function fetchNameItems()
    {
        return [
            'SMS_153055065' => ['code'],
            'SMS_153055066' => ['code', 'address'],
        ];
    }
}
```

### 备注

[](#备注)

1、使用阿里云发送短信时 $sdkAppId 无效（不需要此参数）；

2、使用阿里云发送短信时若 $content 结构是阿里云格式时 $templateParamsModel 无效（不需要此参数）；

3、阿里云 AccessKeyId 和 AccessKeySecret 为[子账号 AccessKey](https://help.aliyun.com/document_detail/53045.html) ；

4、本地 http 请求错误：(cURL error 60: SSL certificate problem: unable to get local issuer certificate.)。

4.1 下载 cacert.pem （）；

4.2 修改 php.ini 修改 curl.cainfo 文件路径（绝对路径）：

```
[curl]
curl.cainfo = "/cacert.pem"

```

###  Health Score

29

—

LowBetter than 63% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

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

Recently: every ~131 days

Total

6

Last Release

1782d ago

Major Versions

v0.1 → v1.02019-11-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/30b3d8cc986a1ad37a55169b11812fea1cae31430dd8dbe1b3436dc58cc885bd?d=identicon)[seffeng](/maintainers/seffeng)

---

Top Contributors

[![seffeng](https://avatars.githubusercontent.com/u/3509779?v=4)](https://github.com/seffeng "seffeng (13 commits)")

---

Tags

phplaravelsmsyii2seffeng

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

119209.9k1](/packages/ellaisys-aws-cognito)[ferdous/laravel-otp-validate

Laravel package for OTP validation with built-in features like retry and resend mechanism. Built in max retry and max resend blocking. OTP/Security Code can be send over SMS or Email of your choice with user-defined template.

7024.3k](/packages/ferdous-laravel-otp-validate)[djunehor/laravel-sms

Send SMS from your laravel application

385.3k1](/packages/djunehor-laravel-sms)

PHPackages © 2026

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