jamesi/notification-bundle
Composer 安装命令:
composer require jamesi/notification-bundle
包简介
Create an email and on-site notification/alerts system for your users
关键字:
README 文档
README
This Symfony bundle allows the creation of a notification system for registered members of a site. Similar to that seen on sites like Facebook.
A Notification corresponds to an event which happened on the site which the user should be made aware about. The Notification class contains the logic to build the views needed for the Alert and email which will be sent to the user.
An Alert is an on-site notification - you should implement some section on the site where the user can see their history of Alerts, and probably let them see their unseen Alert count at all times.
The Notifier, when provided with a Notification, may fire an email and/or
Alert, depending on the user's preferences (must be implemented through
NotifiableInterface).
Usage
- Add the bundle to your composer.json (note: this bundle hasn't reached a stable version yet:
{ "require": { "jamesi/notification-bundle": "dev-master" } }
- Add the bunlde to your AppKernel
public function registerBundles() { $bundles = array( ... new Jamesi\NotificationBundle\JamesiNotificationBundle(), }
- Make your User class implement the
NotifiableInterface:
public function getNotificationName() { // Who should the email be addressed to? return $this->getUsername(); } public function getNotificationEmail() { // Who should the email be addressed to? return $this->getEmail(); } public function acceptsNotificationAlert($type) { // Implement logic here for which on-site alerts the user wants return true; } public function acceptsNotificationEmail($type) { // Implement logic here for unsubscribing from types of email notification return true; }
- Create an entity which extends the provided Alert entity, give it an ID and an entity type (i.e. your User implementation) for the $user ManyToOne relationship
<?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Jamesi\NotificationBundle\Entity\Alert as BaseAlert; /** * @ORM\Entity * @ORM\Table(name="alert") */ class Alert extends BaseAlert { /** * @var int * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var User * @ORM\ManyToOne(targetEntity="User") */ protected $user; }
- Configure the bundle in
app/config/config.yml:
jamesi_notification: alert_class: AppBundle\Entity\Alert from_email: address: myapp@example.com sender_name: My App Name
-
Start creating Notification subclasses in your bundle (see
FooNotificationfor an example) -
In your controllers, use the
jamesi_notification.notifierservice (an instance of theNotifierclass) to send out notifications, using thenotifymethod.
jamesi/notification-bundle 适用场景与选型建议
jamesi/notification-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「notifications」 「alerts」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jamesi/notification-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jamesi/notification-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jamesi/notification-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
Add visual alerts / warnings to Flarum posts
Laravel package for managing session messages and alerts in view responses
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
Bootstrap alerts
统计信息
- 总下载量: 36
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-20