承接 ocuru/notifyme 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ocuru/notifyme

Composer 安装命令:

composer require ocuru/notifyme

包简介

Allows applications to Notify users via various sources.

README 文档

README

Note: This package is under heavy development and is not recommended for production.

Installing New

Install using Composer.

Installing

Install using Composer.

{
	"require": {
		"ocuru/notify": "dev-master"
	}
}

Available Services

Below are the services we currently support, more will be added over time.

Email Service

Service ID Data Required for Notification Optional Data
email ToName, ToEmail, FromName, FromEmail, Subject, MessagePlainText isHTML, MessageHTML (if isHTML = true), ReplyToName, ReplyToEmail
Data
$Notify->ToName = "John Smith";
$Notify->ToEmail = "john@smith.com";

$Notify->FromName = "No Reply - Ocuru";
$Notify->FromEmail = "no-reply@ocuru.com";

// ReplyTo isnt Required
$Notify->ReplyToName = "Support - Ocuru";
$Notify->ReplyToEmail = "support@ocuru.com";

$Notify->Subject = "Example Notification";
$Notify->isHTML = true;
$Notify->MessagePlainText = "This is a example notification message.";
$Notify->MessageHTML = "<html><body><p>This is a example notification message.</p></body></html>";
Service ID Data Required for Notification Optional Data
email to.name, to.email, from.name from.email, message.is_html, message.plain_text message.html (if message.is_html = true)
Data Format
$data = [
	"to" => [
    	"name" => to.name,
      	"email" => to.email
    ],
  	"from" => [
    	"name" => from.name,
      	"email" => from.email
    ],
  	"message" => [
      	"is_html" => true,
      	"html" => "<html><body><p>This is a example notification message.</p></body></html>",
    	"plain_text" => "This is a example notification message."
    ]
];

Twilio Service

Service ID Data Required for Notification
twilio ToPhoneNumber, FromSMSName, FromPhoneNumber, MessageSMS
Data
$Notify->ToPhoneNumber = "07704810577";

$Notify->FromSMSName = "Ocuru";
$Notify->FromPhoneNumber = "447733806389"; // Valid Twilio Number with Country Prefix

// Below Message will send with the following format.
// From Ocuru: This is a example notification message.
$Notify->MessageSMS = "This is a example notification message."; 

Basic Setup

Service ID Data Required for Notification
twilio to.name, to.number, from.name, from.number, message.short
Data Format
$data = [
	"to" => [
      	"name" => to.name,
    	"number" => to.number
    ],
  	"from" => [
       	"name" => from.name,
    	"number" => from.number
    ],
  	"message" => [
    	"short" => message.short
    ]
];

Basic Setup

Below is the basic setup you need to run the example code in this document.

use Ocuru\Notify\Notify;

$Notify = new Notify;

Environmental Variables

You need to first set the .env file location using the below code. This is required.

$_ENV['ENV_LOCATION'] = __DIR__; // Directory of which your .env file is located

If you haven't already set up your .env file , ocuru/notify installs vlucas/phpdotenv onto the system.

Below is the basic setup of Dotenv where $_ENV['ENV_LOCATION'] is the location of your .env file.

Place the below code before the $Notify variable if setup is needed.

$dotenv = new Dotenv\Dotenv($_ENV['ENV_LOCATION']);
$dotenv->load();

Each service will need a different set some .env variables, these are show below.

Email

======= To set up each service you will need to set some .env variables, these are show below.

Email

Ocuru\Notify\Email.SSL.Verify_Peer=false
Ocuru\Notify\Email.SSL.Verify_Peer_Name=false
Ocuru\Notify\Email.SSL.Allow_Self_Signed=true
Ocuru\Notify\Email.Host=mail.example.com
Ocuru\Notify\Email.SMTPAuth=true
Ocuru\Notify\Email.Username=user@example.com
Ocuru\Notify\Email.Password=secret
Ocuru\Notify\Email.SMTPSecure=tls
Ocuru\Notify\Email.Mailer=smtp
Ocuru\Notify\Email.Port=587

Twilio

Ocuru\Notify\Twilio.SID=example_id
Ocuru\Notify\Twilio.Token=example_secret

After Setting .env Variables

In the below example we show you how to setup the services you want to use. You should only run these methods once you have set up all the environmental variables you need shown here. If you don't then an exception will be thrown.

The array can consist of any of the service names shown in the Service ID part of each service List of Services area.

Ocuru\Notify\Twilio.ID=example_id
Ocuru\Notify\Twilio.Secret=example_secret

After Setting .env Variables

In the below example we show you how to setup the services you want to use. You should only run these methods once you have set up all the environmental variables you need shown here. If you don't then an exception will be thrown.

The array can consist of any of the service names shown in square brackets in the List of Services area.

$Notify->use($arrayOfServices);
$Notify->start();

The $Notify->start(); method is required for Ocuru\Notify to initialize. However the $Notify->use(); method isn't required but if you run $Notify->start(); without it we will attempt to setup the Email service which is Ocuru\Notify's default service. If no Environmental Variables are found for the Email Service then a exception will be thrown.

Notifying Users

To notify a user you can use the methods shown below. If an error occurs, we will throw an exception.

Below is the first example of how to send a notification, this sends a notification through all services you have set up.

In order to send a notification you will need to make sure all variables needed for each service are set. You can find out how to do this and what variables are required here.

$Notify->notify();

However you can also send via specific services using the same method, all you need to do is pass an array of services as the first parameter. For Example.

$Notify->notify($arrayOfServices);

The $Notify->start(); method is required for Ocuru\Notify to initialize. However the $Notify->use(); method isn't required but if you run $Notify->start(); without it we will attempt to setup the Email service which is set and Global Default. If no Environmental Variables are found for the Email Service then a exception will be thrown.

Notifying Users

To notify a user you can use the methods shown below.

Below is the first example of how to send a notification, this sends a notification through all services you have set up.


The next example shows you how to send a notification using a specific service. Through the $Notify->notify($data); method.


The final example shows you how to send a notification using the services base Notify Method. For example $Notify->email->notify($data);



                                    

ocuru/notifyme 适用场景与选型建议

ocuru/notifyme 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 07 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「notification」 「slim」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ocuru/notifyme 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ocuru/notifyme 我们能提供哪些服务?
定制开发 / 二次开发

基于 ocuru/notifyme 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-11