fanout / fanout
2.1.0
2017-05-23 19:34 UTC
Requires
- php: >=5.3.0
- fanout/pubcontrol: ^2.0.0
- firebase/php-jwt: ~4.0
Requires (Dev)
- phpunit/phpunit: 3.7.14
This package is not auto-updated.
Last update: 2021-08-31 00:41:04 UTC
README
作者:Konstantin Bokarius kon@fanout.io
一个用于通过 EPCP 协议将消息发布到 Fanout.io 的 PHP 便利库。
许可证
php-fanout 在 MIT 许可证下提供。查看 LICENSE 文件。
要求
- openssl
- curl
- pthreads(用于异步发布,必需)
- firebase/php-jwt >=1.0.0(通过 Composer 自动获取)
- fanout/php-pubcontrol >=1.0.6(通过 Composer 自动获取)
安装
使用 Composer: 'composer require fanout/fanout'
手动:确保已包含 php-jwt 和 php-pubcontrol,并在 php-fanout 中包含以下文件
require 'php-fanout/src/jsonobjectformat.php'; require 'php-fanout/src/fanout.php';
异步发布
为了进行异步发布调用,必须安装 pthreads。如果没有安装 pthreads,则只能进行同步发布调用。要安装 pthreads,请使用以下标志重新编译 PHP:'--enable-maintainer-zts'
请注意,由于传递给 publish_async 方法的回调将在单独的线程中执行,因此该回调及其所属的类将受 pthreads 扩展施加的规则和限制。
有关 pthreads 的更多信息,请参阅: https://php.ac.cn/manual/en/book.pthreads.php
使用方法
<?php $fanout = new Fanout\Fanout('<realm>', '<realmkey>'); $fanout->publish('<channel>', 'Test publish!'); // Use publish_async for async publishing only if pthreads are installed: // $fanout->publish_async('<channel>', 'Test async publish!', null, null, // 'callback'); ?>