PHPackages                             liuwave/think-notification-easysms-channel - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. liuwave/think-notification-easysms-channel

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

liuwave/think-notification-easysms-channel
==========================================

 EasySms Notification channel For ThinkPHP6

1.0.1(6y ago)3311Apache-2.0PHP

Since Dec 7Pushed 6y ago1 watchersCompare

[ Source](https://github.com/liuwave/thinkphp-notification-easysms-channel)[ Packagist](https://packagist.org/packages/liuwave/think-notification-easysms-channel)[ RSS](/packages/liuwave-think-notification-easysms-channel/feed)WikiDiscussions master Synced 2d ago

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

EasySms Notification channel For ThinkPHP6
==========================================

[](#easysms-notification-channel--for-thinkphp6)

使用 [overtrue/easy-sms](https://github.com/overtrue/easy-sms) 发送 ThinkPHP6 消息通知。

安装
--

[](#安装)

```
$ composer require liuwave/think-notification-easysms-channel
```

配置
--

[](#配置)

1、安装插件会自动生成 `config/easysms.php` 文件，若未生成，可以执行以下命令：

```
$ php think vendor:publish
```

2、在`config/easysms.php` 中修改配置。

使用
--

[](#使用)

### 1、创建通知

[](#1创建通知)

通知类，需要实现`channels`和`toEasySms`方法

```
namespace app\common\notification;

use liuwave\notification\channel\EasySms as EasySmsChannel;
use liuwave\notification\message\EasySms as EasySmsMessage;
use yunwuxin\Notification;

/**
 * Class ValidateCode
 * @package app\common\notification
 */
class ValidateCode extends Notification
{

    /**
     * @var string
     */
    public $code = '';
    /**
     * @var string
     */
    public $template = "";

    /**
     * ValidateCode constructor.
     *
     * @param        $template
     * @param string $code
     */
    public function __construct(string $template, string $code = '')
    {
        $this->template = $template;
        $this->code      = $code;

    }

    /**
     * @inheritDoc
     */
    public function channels($notifiable)
    {
        return [ EasySmsChannel::class ];
    }

    /**
     * @param \yunwuxin\notification\Notifiable $notifiable
     *
     * @return \liuwave\notification\message\EasySms
     */
    public function toEasySms($notifiable)
    {
        return ( new EasySmsMessage )->setContent('验证码是$code')
          ->setTemplate($this->template)
          ->setData([
            'code' => empty($this->code) ? rand(1000, 9999) : $this->code,
          ]);
    }

}
```

### 发送短信通知

[](#发送短信通知)

继承创建手机号码类,需要插入trait `yunwuxin\notification\Notifiable` ，这里直接继承`\Overtrue\EasySms\PhoneNumber`，并实现`prepareEasySms`方法。

```
namespace app\common\notification\user;

use yunwuxin\notification\Notifiable;

/**
* Class PhoneNumber
* @package app\common\notification\notifiable
* @mixin  Notifiable
*/
class PhoneNumber extends \Overtrue\EasySms\PhoneNumber
{
   use Notifiable;

   /**
    * @return $this
    */
   public function prepareEasySms()
   {
       return $this;
   }

}
```

执行发送短信

```
        $to = '181*****932';
        // 使用 Notifiable Trait 发送
        (new \app\common\notification\user\PhoneNumber($to))
            ->notify(new \app\common\notification\ValidateCode('SMS_15****670'));

        // 使用 Notification Facade 发送
        \yunwuxin\facade\Notification::send( new \app\common\notification\user\PhoneNumber($to),
                new \app\common\notification\ValidateCode('SMS_15****670'));

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

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

Total

2

Last Release

2348d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea0000cba67ced68f357012faa62e87dacfcf16716cf1a0bef43958da234ebb5?d=identicon)[liuwave](/maintainers/liuwave)

---

Top Contributors

[![liuwave](https://avatars.githubusercontent.com/u/6533126?v=4)](https://github.com/liuwave "liuwave (5 commits)")

### Embed Badge

![Health badge](/badges/liuwave-think-notification-easysms-channel/health.svg)

```
[![Health](https://phpackages.com/badges/liuwave-think-notification-easysms-channel/health.svg)](https://phpackages.com/packages/liuwave-think-notification-easysms-channel)
```

###  Alternatives

[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[leonis/easysms-notification-channel

EasySms Notification Channel for Laravel.

15839.6k](/packages/leonis-easysms-notification-channel)[netflie/laravel-notification-whatsapp

Laravel notification driver for WhatsApp

176173.9k](/packages/netflie-laravel-notification-whatsapp)[ibrand/laravel-sms

ibrand laravel sms base overtrue's easy-sms

7125.9k7](/packages/ibrand-laravel-sms)[yunwuxin/think-notification

The Notification Library For ThinkPHP6

422.2k4](/packages/yunwuxin-think-notification)

PHPackages © 2026

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