waltertamboer / communicator
一个PHP库,通过广播消息到一个或多个频道来帮助进行通信。
dev-master / 1.0.x-dev
2020-01-25 23:00 UTC
Requires
- php: ^7.1
Requires (Dev)
- laminas/laminas-mail: ^2.10
- laminas/laminas-view: ^2.11
- phpmailer/phpmailer: ^5.2
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: ^3.0
- swiftmailer/swiftmailer: ^6.0
Suggests
- laminas/laminas-mail: To send e-mails using Laminas\Mail.
- laminas/laminas-view: To render e-mails using Laminas\View.
- phpmailer/phpmailer: To send e-mails using PHPMailer.
- swiftmailer/swiftmailer: To send e-mails using SwiftMailer.
This package is auto-updated.
Last update: 2024-08-26 09:27:51 UTC
README
Communicator 是一个PHP库,可以帮助你通过多个频道广播消息。当你想要通过电子邮件、短信或IRC等多种传输方式向用户发送通知时,这非常有用。
安装
通过 Composer
$ composer require waltertamboer/communicator
用法
由于communicator不知道要将消息发送到何处,您需要实现 Communicator\Recipient\RecipientInterface
接口。Communicator 将使用它来确定目标地址。
$recipient = new ... // An implementation of Communicator\Recipient\RecipientInterface $communicator = new Communicator\Communicator(); // Bind a transport. Of course this can be any transport you require. // It's also possible to bind multiple transports to the same channel. $communicator->bindTransport('my-channel', new Communicator\Transport\Noop\Transport()); // Now broadcast a message to all transports. $communicator->broadcast( [ $recipient, ], 'my-channel', [ 'my-param' => 'some param', ] );
变更日志
有关最近变更的更多信息,请参阅 CHANGELOG。
测试
$ composer test
贡献
通过 Docker 安装依赖项
docker run --rm --interactive --tty \ --volume $PWD:/app \ --volume $SSH_AUTH_SOCK:/ssh-auth.sock \ --volume /etc/passwd:/etc/passwd:ro \ --volume /etc/group:/etc/group:ro \ --user $(id -u):$(id -g) \ --env SSH_AUTH_SOCK=/ssh-auth.sock \ composer install
运行单元测试
只需确保存在单元测试即可 :-)
鸣谢
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件。