quipo/kafka-php
Composer 安装命令:
composer require quipo/kafka-php
包简介
PHP client library for Apache Kafka 0.7
README 文档
README
kafka-php allows you to produce messages to the Apache Kafka distributed publish/subscribe messaging service.
Requirements
- Minimum PHP version: 5.3.3.
- Apache Kafka 0.6.x or 0.7.x.
- You need to have access to your Kafka instance and be able to connect through TCP. You can obtain a copy and instructions on how to setup kafka at https://github.com/kafka-dev/kafka
- The PHP Zookeeper extension is required if you want to use the Zookeeper-based consumer.
Installation
Add the lib directory to the PHP include_path and use an autoloader like the one in the examples directory (the code follows the PEAR/Zend one-class-per-file convention).
Usage
The examples directory contains an example of a Producer and a simple Consumer, and an example of the Zookeeper-based Consumer.
Example Producer:
$producer = new Kafka_Producer('localhost', 9092, Kafka_Encoder::COMPRESSION_NONE); $messages = array('some', 'messages', 'here'); $topic = 'test'; $bytes = $producer->send($messages, $topic);
Example Consumer:
$topic = 'test'; $partition = 0; $offset = 0; $maxSize = 1000000; $socketTimeout = 5; while (true) { $consumer = new Kafka_SimpleConsumer('localhost', 9092, $socketTimeout, $maxSize); $fetchRequest = new Kafka_FetchRequest($topic, $partition, $offset, $maxSize); $messages = $consumer->fetch($fetchRequest); foreach ($messages as $msg) { echo "\nMessage: " . $msg->payload(); } //advance the offset after consuming each MessageSet $offset += $messages->validBytes(); unset($fetchRequest); }
TODO
- support for Snappy compression
Contact for questions
Lorenzo Alberton
l.alberton at(@) quipo.it
quipo/kafka-php 适用场景与选型建议
quipo/kafka-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 105.09k 次下载、GitHub Stars 达 206, 最近一次更新时间为 2018 年 09 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 quipo/kafka-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 quipo/kafka-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 105.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 207
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache
- 更新时间: 2018-09-13