herald-project/client-php
Composer 安装命令:
composer require herald-project/client-php
包简介
Herald client for PHP
README 文档
README
Send beautiful messages from your application.
Installation
composer require herald-project/client-php
Example
use Herald\Client\Client as HeraldClient; use Herald\Client\Message as HeraldMessage; // get the client with explicit parameters $herald = new HeraldClient( '[herald api username]', '[herald api password]', '[herald server uri]', '[herald transport, e.g. smtp]'), '[herald account]', '[herald library]', ); // get the client by DSN $herald = HeraldClient::fromDsn('https://username:password@herald.dev/myAccount/myLibrary/myTransport'); // check template existance. if ($herald->templateExists('signup')) { // get the message $message = new HeraldMessage(); // use the template $message->setTemplate('signup'); // set to address $message->setToAddress($emailAddress, $customerName); // populate data $message->setData('firstname', 'Hongliang'); $message->setData('nickname', 'exploder hater'); // send $herald->send($message); }
CLI usage
You can use the bin/herald-client CLI application to run commands against your herald server.
The application needs a couple of configuration directives to work:
- username + password: The account you use to connect. Either a user account, or an API key+secret pair
- apiurl: the base url of herald, (i.e. https://herald.dev) with postfix
/api/v2 - account + library: This is the library identifier you use to create your templates, layouts and transports
You can pass this data in 3 ways:
Individual options:
For example:
./bin/herald-client --username=x --password=y --apiurl=https://herald.dev/api/v2 --account=test --library=test template:exists welcome
A single DSN
For example:
./bin/herald-client --dsn=https://x:y@herald.dev/test/test/mandrill
By environment variables
You can define the environment variable HERALD_DSN with a valid URL, this way you don't
need to pass any options to the CLI application
By .env
The Herald CLI application loads .env before running any commands, allowing you to create a .env file
like this:
HERALD_DSN=https://x:y@herald.dev/test/test/mandrill
This way you also don't need to pass any options for each command
Example commands
# get list of all contact lists
bin/herald-client list:list
# get list of contacts in contact list #1
bin/herald-client list:contacts 1
# get list of segments for list #1
bin/herald-client list:segments 1
# get available list_fields for list #1
bin/herald-client list:fields 1
# delete contact #42
#bin/herald-client contact:delete 42
# get properties of contact #6
bin/herald-client contact:properties 6
# add new contact with address 'new.contact@example.com' to list #1
bin/herald-client contact:add 1 new.contact@example.com
# add new property to contact #36 for list field id #4
bin/herald-client property:add 36 4 "some value"
# send message based on template #7 to all contacts in list #1
bin/herald-client list:send 1 7
# send message based on template #1 to contacts in list #1 that meet the conditions for segment #6
bin/herald-client list:send 1 7 6
herald-project/client-php 适用场景与选型建议
herald-project/client-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.14k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「smtp」 「templates」 「mandrill」 「mailgun」 「messages」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 herald-project/client-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 herald-project/client-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 herald-project/client-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
CakePHP 4.x AdminLTE Theme.
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
CakePHP 3.x Gentelella Theme.
Extensible library for building notifications and sending them via different delivery channels.
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
统计信息
- 总下载量: 6.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-07