notifymehq / notifyme
此包已被废弃,不再维护。没有建议的替代包。
提供通知服务的通用接口
dev-master / 1.0.x-dev
2016-02-05 14:10 UTC
Requires
- php: >=5.5.9
- guzzlehttp/guzzle: ^5.3|^6.0
Requires (Dev)
- phpunit/phpunit: ^4.8|^5.0
Replaces
- notifymehq/ballou: dev-master
- notifymehq/campfire: dev-master
- notifymehq/contracts: dev-master
- notifymehq/factory: dev-master
- notifymehq/gitter: dev-master
- notifymehq/hipchat: dev-master
- notifymehq/http: dev-master
- notifymehq/manager: dev-master
- notifymehq/pagerduty: dev-master
- notifymehq/pushover: dev-master
- notifymehq/slack: dev-master
- notifymehq/support: dev-master
- notifymehq/twilio: dev-master
- notifymehq/webhook: dev-master
- notifymehq/yo: dev-master
This package is not auto-updated.
Last update: 2022-02-01 12:53:57 UTC
README
通知服务的通用接口。
安装
需要PHP 5.5+ 或 HHVM 3.6+。
要获取NotifyMe的最新版本,只需使用Composer引入项目。
$ composer require notifymehq/notifyme
当然,您也可以手动更新require块并运行composer update
。
{ "require": { "notifymehq/notifyme": "^1.0" } }
如果您想要,您只需要求单个适配器。这类似于laravel或symfony的组件系统。我们目前有以下适配器
- Ballou (
notifymehq/ballou
) - Campfire (
notifymehq/campfire
) - Gitter (
notifymehq/gitter
) - Hipchat (
notifymehq/hipchat
) - Pagerduty (
notifymehq/pagerduty
) - Pushover (
notifymehq/pushover
) - Slack (
notifymehq/slack
) - Twilio (
notifymehq/twilio
) - Webhook (
notifymehq/webhook
) - Yo (
notifymehq/yo
)
此外,请注意,我们的其他组件有
- Contracts (
notifymehq/contracts
) - Factory (
notifymehq/factory
) - Http (
notifymehq/http
) - Manager (
notifymehq/manager
) - Support (
notifymehq/support
)
最后,我们有一个完全独立的Laravel桥接器可供使用,方法是安装notifyme/laravel
,然后添加我们的服务提供者:NotifyMeHQ\Laravel\NotifyMeServiceProvider
。
使用方法
- 创建一个工厂:
$factory = new NotifyMeHQ\Factory\NotifyMeFactory();
- 制作一个通知器:
$notifier = $factory->make($config);
- 通知:
$response = $notifier->notify($to, $message);
- 检查响应:
$response->isSent();
示例
以下是一个使用Slack的示例通知
<?php // Create a factory for notifications $notifierFactory = new NotifyMeHQ\Factory\NotifyMeFactory(); // Create the new notification for slack $slackNotifier = $notifierFactory->make([ // Specify that we will use slack 'driver' => 'slack', // Add api token to get access to slack API 'token' => '', // Who send this message, here is a bot called 'Super Bot' 'from' => 'Super Bot', ]); /* @var \NotifyMeHQ\Contracts\ResponseInterface $response */ $response = $slackNotifier->notify('#sandbox', 'test message'); echo $response->isSent() ? 'Message sent' : 'Message going nowhere';
许可证
NotifyMe遵循MIT许可证(MIT)。