PHPackages                             yzh52521/think-notification - 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. yzh52521/think-notification

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

yzh52521/think-notification
===========================

The Notification Library For ThinkPHP6

v2.0.2(2y ago)41421Apache-2.0PHPPHP &gt;=8.0.2

Since Sep 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/yzh52521/think-notification)[ Packagist](https://packagist.org/packages/yzh52521/think-notification)[ RSS](/packages/yzh52521-think-notification/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (18)Used By (1)

ThinkPHP6+ 消息通知扩展
=================

[](#thinkphp6-消息通知扩展)

支持`mail` `sms` `easysms` `database`等驱动

应用场景
----

[](#应用场景)

> 发送手机验证码
> 发送验证邮件，找回密码邮件 订单状态变更
> 站内消息通知
> ...

安装
--

[](#安装)

```
composer require yzh52521/think-notification

```

创建通知
----

[](#创建通知)

通常每个通知都由一个存储在 app/notifications 目录下的一个类表示。如果在你的应用中没有看到这个目录，不要担心，当运行 make:notification 命令时它将为您创建：

```
php think make:notification InvoicePaid
```

这个命令会在 app/notifications 目录下生成一个新的通知类。每个通知类都包含一个 channels 方法以及一个或多个消息构建的方法比如 toMail 或 toDatabase，它们会针对特定的渠道把通知转换为对应的消息。

发送通知
----

[](#发送通知)

使用 Notifiable Trait

通知可以通过两种方式发送： 使用 Notifiable 特性的 notify 方法或使用 Notification 门面

```
