Download the PHP package grongor/kafka-rest-client without Composer

On this page you can find all versions of the php package grongor/kafka-rest-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package kafka-rest-client

kafka-rest-client Build Status

This is a modern PHP client for Confluent REST Proxy (version 2).

HTTP client used for communication with API adheres to the modern HTTP standards like PSR-7, PSR-17 and PSR-18.

Aside from implementing the REST Proxy API this library adds some convenient classes useful for the most interactions with Apache Kafka - see examples for the whole list and a simple tutorial on how to use them.

Missing features

Some features were deliberately skipped to simplify the implementation/shorten the development time. If you need anything and you're willing create a pull request, I'd be happy to check it out and (if it makes sense) merge it. You can start the discussion by opening an issue.

Examples

Producer

Producer allows you to produce messages, either one by one or in batches. Both use the same underlying API method so it's more efficient to use the batch one.

Both produce and produceBatch return nothing on success and throw an exception on failure. There might be partial success/failure so the thrown exception FailedToProduceMessages contains two public properties, $retryable and $nonRetryable, where each contains an array of ['error' => 'error provided by Kafka', message => (Message object given to produce())]. Whether the error is [non-]retryable is based on the error_code as is documented. It's up to you what you do with those.

Consumer

Consumer allows you to consume messages one by one until you return from the loop, application throws exception or is otherwise forced to exit. The consume method returns a Generator and loops indefinitely, yielding messages as they are available. consume method accepts two parameters: timeout and maxBytes. timeout is the maximum time the consumer will wait for the messages. maxBytes is the maximum size of the messages to fetch in a single request. Both of these settings are complementary to the settings in ConsumerOptions and to the server settings (check the Kafka documentation for more information).

If you set the consumer option autoCommitEnable to false then you may use consumer's commit method to commit messages. Simply pass it a message you wish to commit. For most cases it's recommended to turn off the auto-commit and manually commit each message, so that you don't ever "lose" a message if your application dies in the middle of the processing.

You can also (optionally) set an idle callback using setIdleCallback method. This callback will be called whenever there are no messages to yield. The idle interval is then equal to the timeout parameter if provided, or to the consumerRequestTimeoutMs option if set, otherwise to the proxy configuration option consumer.request.timeout.ms.

BatchConsumer

BatchConsumer works the same way as Consumer does; the difference is that BatchConsumer doesn't yield each message separately but first puts them in batches (MessagesBatch). These batches can be configured to be "limited" by either count of messages in the batch (maxCount), by time (maxDuration) or by both (setting both maxCount and maxDuration). If you set maxDuration then the batch won't ever take longer than that (+ few ms for processing) as it changes the timeout parameter of the consumer (consumer won't get stuck on network waiting for more messages).

BatchConsumer can be quite useful for processing of "large" data sets, where you would have to otherwise batch the messages yourself (eg. for inserting into database, where batch operations are always better).

As mentioned in the Consumer example, you may need to commit the messages. For that there is a commit method, which accepts the yielded MessagesBatch and commits all the messages inside it in one request.


All versions of kafka-rest-client with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.0
beberlei/assert Version ^3.2
bentools/iterable-functions Version ^1.2
jms/serializer Version ^3.2
lcobucci/clock Version ^1.2
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.0.1
psr/log Version ^1.1
teapot/status-code Version ^1.1
thecodingmachine/safe Version ^0.1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package grongor/kafka-rest-client contains the following files

Loading the files please wait ....