PHP code example of jobcloud / php-kafka-schema-registry-client
1. Go to this page and download the library: Download jobcloud/php-kafka-schema-registry-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jobcloud / php-kafka-schema-registry-client example snippets
use Buzz\Client\Curl;
use Jobcloud\Kafka\SchemaRegistryClient\ErrorHandler;
use Jobcloud\Kafka\SchemaRegistryClient\HttpClient;
use Jobcloud\Kafka\SchemaRegistryClient\KafkaSchemaRegistryApiClient;
use Nyholm\Psr7\Factory\Psr17Factory;
-server-url:9081',
$username ?? null,
$password ?? null
);
$schema = '{"type":"record","name":"something","namespace":"whatever.you.want","fields":[{"name":"id","type":"string"}]}';
$registryClientApi = new KafkaSchemaRegistryApiClient($registryClient);
$subjectName = 'some.subject.name';
$results = $registryClientApi->getVersionForSchema($subjectName, $schema);
use Jobcloud\Kafka\SchemaRegistryClient\ServiceProvider\KafkaSchemaRegistryApiClientProvider;
use Pimple\Container;
$container = new Container();
$container['kafka.schema.registry'] = [
'base.url' => 'http://your-registry-schema-server-url:9081',
'username' => 'your_username',
'password' => 'your_password',
];
$container->register(new KafkaSchemaRegistryApiClientProvider());
$api = $container['kafka.schema.registry.client.api']);
$data = $api->getSubjects();