PHPackages                             youyiio/beyong-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. [Queues &amp; Workers](/categories/queues)
4. /
5. youyiio/beyong-sms

ActiveLibrary[Queues &amp; Workers](/categories/queues)

youyiio/beyong-sms
==================

A powerful and beautiful php sms for All of ThinkPHP and Other PHP Frameworks,suport alisms,tencent sms,jiguang sms.一款支持多家短信服务商的优雅短信发送库，ThinkPHP系列框架【5.0.x,5.1.x,6.0.x】开箱即用，其他框架初始化配置即可使用。基于阿里云、腾讯云、极光最新短信发送功能的极简包 二次开发, 为 ThinkPHP系列框架量身定制, 使 ThinkPHP 支持邮件模板、纯文本、附件邮件发送以及更多邮件功能, 邮件发送简单到只需一行代码。

v0.9.4(4y ago)41.6k1Apache-2.0PHPPHP &gt;=5.4.0

Since Aug 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/youyiio/beyong-sms)[ Packagist](https://packagist.org/packages/youyiio/beyong-sms)[ Docs](https://www.beyongx.com)[ RSS](/packages/youyiio-beyong-sms/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (1)

beyong-sms
==========

[](#beyong-sms)

**一款支持多家短信服务商优美的短信发送库**，ThinkPHP系列框架【5.0.x,5.1.x,6.0.x】开箱即用，其他框架初始化配置即可使用

基于 阿里云、腾讯云、极光最新短信发送功能的极简包 二次开发, 为ThinkPHP系列框架量身定制, 使 ThinkPHP 支持短信模板、纯文本发送以及更多短信功能, 短信发送简单到只需一行代码

[github地址](https://github.com/youyiio/beyong-sms)

目录
--

[](#目录)

- [优雅的发送短信](#%E4%BC%98%E9%9B%85%E7%9A%84%E5%8F%91%E9%80%81%E7%9F%AD%E4%BF%A1)
- [安装](#%E5%AE%89%E8%A3%85)
    - [使用 Composer 安装 (强烈推荐)](#%E4%BD%BF%E7%94%A8-composer-%E5%AE%89%E8%A3%85-%E5%BC%BA%E7%83%88%E6%8E%A8%E8%8D%90)
    - [github下载 或 直接手动下载源码](#github%E4%B8%8B%E8%BD%BD-%E6%88%96-%E7%9B%B4%E6%8E%A5%E6%89%8B%E5%8A%A8%E4%B8%8B%E8%BD%BD%E6%BA%90%E7%A0%81)
        - [下载文件](#%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6)
        - [引入自动载入文件](#%E5%BC%95%E5%85%A5%E8%87%AA%E5%8A%A8%E8%BD%BD%E5%85%A5%E6%96%87%E4%BB%B6)
- [配置](#%E9%85%8D%E7%BD%AE)
    - [部分配置详解](#%E9%83%A8%E5%88%86%E9%85%8D%E7%BD%AE%E8%AF%A6%E8%A7%A3)
- [使用](#%E4%BD%BF%E7%94%A8)
    - [使用beyong-sms](#%E4%BD%BF%E7%94%A8beyong-sms)
    - [创建实例](#%E5%88%9B%E5%BB%BA%E5%AE%9E%E4%BE%8B)
    - [设置收件人](#%E8%AE%BE%E7%BD%AE%E6%94%B6%E4%BB%B6%E4%BA%BA)
    - [设置发件人](#%E8%AE%BE%E7%BD%AE%E5%8F%91%E4%BB%B6%E4%BA%BA)
    - [设置短信主题](#%E8%AE%BE%E7%BD%AE%E7%9F%AD%E4%BF%A1%E4%B8%BB%E9%A2%98)
    - [设置短信内容 - template](#%E8%AE%BE%E7%BD%AE%E7%9F%AD%E4%BF%A1%E5%86%85%E5%AE%B9-template)
    - [设置短信内容](#%E8%AE%BE%E7%BD%AE%E7%9F%AD%E4%BF%A1%E5%86%85%E5%AE%B9)
    - [发送短信](#%E5%8F%91%E9%80%81%E7%9F%AD%E4%BF%A1)
- [Issues](#issues)
- [License](#license)

优雅的发送短信
-------

[](#优雅的发送短信)

**ThinkPHP5/6 示例**

```
use beyong\sms\SmsClient;

$client = SmsClient::instance();
$client->to('177xxxxx')
    ->template('temp_id', $data)
    ->sign('sign_id')
    ->send();

```

安装
--

[](#安装)

### 使用 Composer 安装 (强烈推荐):

[](#使用-composer-安装-强烈推荐)

支持 `psr-4` 规范, 开箱即用

```
composer require youyiio/beyong-sms

```

### github下载 或 直接手动下载源码:

[](#github下载-或-直接手动下载源码)

需手动引入自动载入文件

#### 下载文件:

[](#下载文件)

git clone  beyong-sms

#### 引入自动载入文件:

[](#引入自动载入文件)

使用时引入或者全局自动引入

`require_once '/path/to/beyong-sms/src/autoload.php`;

配置
--

[](#配置)

在配置文件里配置如下信息, 可以配置在 `sms.php` 或 `config.php` 文件中, 内容如下:

```
return [
    'driver'      => 'aliyun', // 服务提供商, 支持 aliyun|tencent|jiguang 三种
    'key'         => '', // 短信服务key
    'secret'      => '', // 短信服务secret
    'SDKAppID'    => '', // 腾讯短信平台需要
    'debug'      => true,
    'log_driver' => '', //\beyong\sms\log\File::class,
    'log_path'   => __DIR__ . '/log'
];

```

### 部分配置详解

[](#部分配置详解)

#### driver

[](#driver)

可选值是字符串，只能是 `aliyun|tencent|jiguang`

#### key &amp; secret

[](#key--secret)

在短信提供商注册时的密钥

#### log\_driver

[](#log_driver)

日志驱动，如果不配置则为类库自带简单的日志驱动 `\beyong\sms\log\File::class`，可自定义配置为框架的日志驱动，例如 `'log_driver' => '\\think\\Log'`，日志驱动类必须实现静态方法 `write`，例如:

```
public static function write($content, $level = 'debug')
{
    echo '日志内容：' . $content;
    echo '日志级别：' . $level;
}

```

#### log\_path

[](#log_path)

日志驱动为默认是日志存储路径，不配置默认为 `beyong-sms/log/`，例如可配置为 `ROOT_PATH . 'runtime/log/'`

使用
--

[](#使用)

以下示例以 ThinkPHP5 里使用为例, 其他框架完全一样

### 使用beyong-sms

[](#使用beyong-sms)

```
// 不支持自动载入的框架请手动引入自动载入文件
// require_once '/path/to/beyong-sms/src/autoload.php';

use beyong\sms\SmsClient

```

### 创建实例

[](#创建实例)

不传递任何参数表示短信驱动使用配置文件里默认的配置

```
$client = SmsClient::instance();

```

### 设置收件人

[](#设置收件人)

以下几种方式任选一种

```
$client->to(['177xxxx']);
$client->to(['177xxxx', '132xxxx']);

```

### 设置短信内容-template

[](#设置短信内容-template)

```
$client->template('欢迎使用beyong-sms');

```

或者使用变量替换模板内容

```
$client->template('欢迎使用{name}', ['name' => 'beyong-sms']);

```

### 设置短信内容

[](#设置短信内容)

```
$client->subject('短信主题');

```

#### 示例

[](#示例)

```
SmsClient::instance()
    ->to('132xxxx')
    ->template('temp_id', [])
    ->sign('sign_id')
    ->send();

```

Issues
------

[](#issues)

如果有遇到问题请提交 [issues](https://github.com/youyiio/beyong-sms/issues)

License
-------

[](#license)

Apache 2.0

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Total

4

Last Release

1705d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0eb11d31135ed8017f5ff6b9decccf7d0cff9cf2a665ae973e5beffb032bad48?d=identicon)[cattong](/maintainers/cattong)

---

Tags

messagesmsaliyuntencentthinkphpjiguangjpushthinkphp5beyong-sms

### Embed Badge

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

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

###  Alternatives

[phlib/sms-length

SMS Length calculations, using GSM 03.38 and GSM 03.40

14807.1k2](/packages/phlib-sms-length)[fotografde/cakephp-sms

SMS Plugin for CakePHP

1273.2k](/packages/fotografde-cakephp-sms)

PHPackages © 2026

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