PHPackages                             apffth/hyperf-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. apffth/hyperf-notification

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

apffth/hyperf-notification
==========================

A notification system for Hyperf framework, compatible with Laravel notifications

v1.2.0(7mo ago)0664[1 PRs](https://github.com/apffth/hyperf-notification/pulls)MITPHPPHP &gt;=8.2CI passing

Since Jul 10Pushed 4d agoCompare

[ Source](https://github.com/apffth/hyperf-notification)[ Packagist](https://packagist.org/packages/apffth/hyperf-notification)[ RSS](/packages/apffth-hyperf-notification/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (22)Versions (7)Used By (0)

Hyperf Notification
===================

[](#hyperf-notification)

[![Latest Version on Packagist](https://camo.githubusercontent.com/610a6aff894bdcded66accf3f2cee86875f81be78766e564542904161ffa282c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6170666674682f6879706572662d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/apffth/hyperf-notification)[![Total Downloads](https://camo.githubusercontent.com/3e9e408d12dee628220b13dbbebfa0ce62360799d209cdffd5138ecff3b4aaad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6170666674682f6879706572662d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/apffth/hyperf-notification)[![License](https://camo.githubusercontent.com/aaf00898272aad1d5aadae7966a7426d5cbb49165edea85e5b314b9fd72c4b70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6170666674682f6879706572662d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/apffth/hyperf-notification/blob/master/LICENSE)[![PHP Version](https://camo.githubusercontent.com/68dcce610b5b9b19c57092006897419a245415c899488bb6fad4a07cdcc06220/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6170666674682f6879706572662d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/apffth/hyperf-notification)[![Hyperf Version](https://camo.githubusercontent.com/9445c288f695922d4e7e71d6f1233f55803e8327416f3cc1155b40ddcc555698/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4879706572662d253345253344332e302d626c75652e7376673f7374796c653d666c61742d737175617265)](https://hyperf.io)[![CI](https://camo.githubusercontent.com/4dc76407bbfa78e18098240d0d23241203aecb8ec333bad730ed7b0bc6e51eac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6170666674682f6879706572662d6e6f74696669636174696f6e2f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/apffth/hyperf-notification/actions/workflows/ci.yml)[![Code Style](https://camo.githubusercontent.com/23fcb18e5e991b1acf97cbf6a2d59fc3fdb7ffe83412db93b523cfe7b09b3e22/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6170666674682f6879706572662d6e6f74696669636174696f6e2f63732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/apffth/hyperf-notification/actions/workflows/cs.yml)[![GitHub Stars](https://camo.githubusercontent.com/c1e55d67f3dea4b4be60935459f5156958d61158d4f896174a101baee005e0e8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6170666674682f6879706572662d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/apffth/hyperf-notification/stargazers)[![GitHub Forks](https://camo.githubusercontent.com/7561a00f64083f527b736567d73344821d4f806c9ae7d67989c2f0815b605ddc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6170666674682f6879706572662d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/apffth/hyperf-notification/network)[![GitHub Issues](https://camo.githubusercontent.com/ca938ad98e699c20e44b2ccd094256e9e6a7c44d8fcf6b0e396a17efe5ff7972/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6170666674682f6879706572662d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/apffth/hyperf-notification/issues)[![GitHub Pull Requests](https://camo.githubusercontent.com/79ddc37269bf5464b69c59752c685ea270714d377f3e5956d6b3df36c7d07cd0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6170666674682f6879706572662d6e6f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/apffth/hyperf-notification/pulls)

一个专为 Hyperf 框架设计的通知系统，兼容 Laravel 通知的 API 设计，提供灵活、可扩展的通知发送功能。

特性
--

[](#特性)

- 🚀 **高性能**: 基于 Hyperf 框架，深度集成异步队列处理。
- 📧 **多渠道支持**: 内置邮件、数据库等核心通知渠道。
- 🔧 **易于扩展**: 支持通过依赖注入方便地集成自定义通知渠道。
- 📝 **事件系统**: 与 Hyperf 原生事件系统无缝集成，提供完整的通知生命周期事件。
- 🎯 **Laravel 兼容**: 核心 API 设计与 Laravel 通知保持一致，易于上手。
- 🎨 **模板支持**: 集成 Twig 模板引擎，支持优雅的邮件模板。

支持的渠道
-----

[](#支持的渠道)

- **邮件 (Mail)**: 使用 Symfony Mailer 发送邮件。
- **数据库 (Database)**: 将通知存储到数据库。
- **自定义渠道**: 支持注册任意自定义通知渠道。

环境要求
----

[](#环境要求)

- PHP &gt;= 8.2
- Hyperf &gt;= 3.0

安装
--

[](#安装)

### 1. 通过 Composer 安装

[](#1-通过-composer-安装)

```
composer require apffth/hyperf-notification
```

### 2. 发布配置文件和迁移

[](#2-发布配置文件和迁移)

```
php bin/hyperf.php vendor:publish apffth/hyperf-notification
```

该命令会发布 `notification.php`, `mail.php`, `twig.php` 配置文件以及数据库迁移文件。

### 3. 运行数据库迁移

[](#3-运行数据库迁移)

```
php bin/hyperf.php migrate
```

使用方法
----

[](#使用方法)

### 1. 创建通知类

[](#1-创建通知类)

使用 `gen:notification` 命令可以快速生成一个通知类。（暂示未支持命令式创建通知类，请手动创建）

```
php bin/hyperf.php gen:notification WelcomeNotification
```

通知类定义了通知的发送逻辑和内容。

```
