nailfor/php-queue-client
Composer 安装命令:
composer require nailfor/php-queue-client
包简介
a queue broker client library for php
README 文档
README
phpQueueClient is an client library for AMQP and MQTT queues server. Its based on the reactPHP socket-client
Goal
Goal of this project is easy to use both AMQP and MQTT client for PHP in a modern architecture without using any php modules. Original idea taken from https://github.com/oliverlorenz/phpMqttClient
-
yes it correctly supports both qos protocols
-
yes it works with huge data in a packet
-
yes it can receive, ping, unsubscribe and publish
-
Protocol specifications: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/csprd02/mqtt-v3.1.1-csprd02.html
Example publish
use nailfor\queue\ClientFactory; use nailfor\queue\protocol\MQTT; class MQTTClass { public function subscribe() { $url = '127.0.0.1:5672'; $options = [ //'username' => '', //'password' => '', 'clientId' => 'php', 'cleanSession' => false, 'topics' => [ 'topic_name' => [ //this flag clear message after reciev. Default true //'clear' => false, 'qos' => 1, //only for MQTT 'message' => 'hello from topic', ], 'capital_name' => [ 'qos' => 2, //only for MQTT 'message' => 'hello from capital', ], ], ]; $protocol = new MQTT; //default AMQP ClientFactory::publish($url, $options, [$this, 'onError'], $protocol); } }
Example subscribe
use nailfor\queue\ClientFactory; use nailfor\queue\protocol\MQTT; use Illuminate\Support\Facades\Log; class MQTTClass { public function onMessage($packet) { //... } public function onCapitalMessage($packet) { //... } public function onError($reason) { echo $reason->getMessage(). PHP_EOL; exit; } public function subscribe() { $url = '127.0.0.1:5672'; $options = [ //'username' => '', //'password' => '', 'clientId' => 'php', 'cleanSession' => false, 'topics' => [ 'topic_name' => [ //this flag clear message after reciev. Default true //'clear' => false, 'qos' => 1, //only for MQTT 'events' => [ 'PUBLISH' => [$this, 'onMessage'], ], ], 'capital_name' => [ 'qos' => 0, //only for MQTT 'events' => [ 'PUBLISH' => [$this, 'onCapitalMessage'], ], ], ], ]; $protocol = new MQTT; //default AMQP $logger = Log::channel('stderr'); //default null ClientFactory::run($url, $options, [$this, 'onError'], $protocol, $logger); } }
also commands are available
ClientFactory::run //subscribe and get messages
ClientFactory::publish
ClientFactory::unsubscribe
ClientFactory::ping
The Logger suppurt 3 level of details: notice, info and debug. Offcourse you can disable it set null in last param
Notice - (Oct 21th, 2020)
Currently work:
-
AMQP implementation:
-
publish.. not yet
-
subscribe
-
unsubscribe
-
MQTT implementation:
-
- qos 1
-
- qos 2
-
subscribe
-
unsubscribe
-
publish
nailfor/php-queue-client 适用场景与选型建议
nailfor/php-queue-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.31k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「AMQP」 「reactphp」 「iot」 「mqtt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nailfor/php-queue-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nailfor/php-queue-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nailfor/php-queue-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple, event-driven multicast UDP message client and server for ReactPHP.
Queue
Work with RabbitMQ in Laravel.
PHP AMQP Binding Library
The Listener component of the RabbitEvents library.
The Publisher component of the RabbitEvents package.
统计信息
- 总下载量: 1.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2019-11-13