PHPackages                             hahadu/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hahadu/sms

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

hahadu/sms
==========

php sms

v1.1.0(1y ago)11132Apache-2.0PHPPHP &gt;=7.4

Since Dec 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hahadu/sms)[ Packagist](https://packagist.org/packages/hahadu/sms)[ RSS](/packages/hahadu-sms/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (3)Versions (7)Used By (2)

sms
===

[](#sms)

聚合短信验证

- 已接入阿里云短信 require php &gt;7.2

#### 使用

[](#使用)

```
use Hahadu\Sms\Client\SmsClient;
//实例化短信方法
//SmsClient支持4个参数
     * @param string $accessSecret Secret key
     * @param string $accessKey Secret key id
     * @param string $signName 短信签名
     * @param string $service 短信服务商 默认aliyun

$sms = New SmsClient('access_secret','access_key','测试签名','aliyun');
```

##### 发送短信

[](#发送短信)

```
//发送短信
    /****
     * @param int|string $phone
     * @param array $smsParam 短信内容
     * @param string $template 短信模板
    */
return $sms->send_sms('18888888888',$smsParam=['code'=>4545],$template='SMS_205*******'); //array
```

##### 查询短信发送记录

[](#查询短信发送记录)

```
    /*****
     * 查询发送记录
     * @param string|int $phone_number 查询手机号
     * @param string|int $current_page 查询页数
     * @param string|int $page_size 每页数量
     * @param mixed $send_date 查询时间
     */
return $sms->query_send_details($phone_number='18000000000',$page=1,$page_size=10,$send_date = "20210701");
```

##### 查询短信模板

[](#查询短信模板)

```
    /*****
     * 查询短信模板
     * @param string $template 短信模板code
     * @return array|string
     */
return $sms->query_sms_template($template);
```

##### 修改短信模板

[](#修改短信模板)

```
    /*****
     * 修改申请失败的短信模板
     * @param int $type 短信类型。其中：
     * 0：验证码。
     * 1：短信通知。
     * 2：推广短信。
     * 3：国际/港澳台消息
     * @param string $template_name 模板名称
     * @param string $template_content 模板内容
     * @param string $remark 短信模板申请说明
     * @param null $template_code 短信模板id
     * @param null $sign 模板签名ID
     * @return array|string
     */
return $sms->edit_sms_template($type, $template_name, $template_content, $remark, $template_code , $sign );
```

##### 添加短信模板

[](#添加短信模板)

```
    /*****
     * 创建短信模板
     * @param int $type 短信类型。其中：
     * 0：验证码。
     * 1：短信通知。
     * 2：推广短信。
     * 3：国际/港澳台消息
     * @param string $template_name 模板名称
     * @param string $template_content 模板内容
     * @param string $remark 短信模板申请说明
     * @param null $sign 模板签名ID
     * @return array|string
     */
    $sms->create_sms_template($type, $template_name, $template_content, $remark, $sign = null);
```

##### 删除短信模板

[](#删除短信模板)

```
    /*****
     * 删除短信模板
     * @param string $template_code 短信模板标识符
     * @return array|string
     */
   $sms->delete_sms_template(string $template_code);
```

#### 在thinkphp6中使用

[](#在thinkphp6中使用)

##### 创建thinkphp配置文件 sms.php

[](#创建thinkphp配置文件-smsphp)

```
config/sms.php
return [
    'default' => 'aliyun', //默认短信服务商
    'service' =>[
        'aliyun'=>[ //短信服务配置
            'access_secret' => 'ztmTzCvpGr****KbceSfXibBS', //secret
            'access_key' => 'LTAI4GCA****DKTbFkYMPD',
            'sign_name'  => '阿里云', //短信签名
            'template'   => 'SMS_205****6', //默认短信模板
        ],
    ],
];
```

配置好参数后直接调用方法即可

##### 控制器方法

[](#控制器方法)

```
namespace app\index\controller;
use Hahadu\Sms\think\ThinkSmsClient;
class Index{

   //发送短信
   dump(ThinkSmsClient::init()->send_sms('18888888888',['code'=>4545],'SMS_205*******'));
   //查询短信发送记录
   dump(ThinkSmsClient::init()->query_send_details('18000000000',1,10,"20210701"));
}
```

### 项目

[](#项目)

[@hahadu主页](http://github.com/hahadu)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance44

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

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

Recently: every ~399 days

Total

6

Last Release

444d ago

Major Versions

v0.3.0 → v1.0.02021-07-12

PHP version history (2 changes)v0.1.0PHP &gt;=5.6

v1.1.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8803f4b62a77e88a2b14f57d7d68a5bacaa69fd8c58b17101e89044fab8abb27?d=identicon)[hahadu](/maintainers/hahadu)

---

Top Contributors

[![hahadu](https://avatars.githubusercontent.com/u/38153732?v=4)](https://github.com/hahadu "hahadu (14 commits)")

### Embed Badge

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

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k42](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[oat-sa/tao-core

TAO core extension

66143.7k121](/packages/oat-sa-tao-core)

PHPackages © 2026

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