jobcloud/php-console-kafka-schema-registry

Kafka模式注册表的命令行工具

v2.3.0 2023-09-19 11:26 UTC

README

安装

composer require jobcloud/php-console-kafka-schema-registry

需求

  • php: >= 7.4

注册命令

您可以将每个命令单独注册,如下所示

<?php

use Symfony\Component\Console\Application;
use Jobcloud\SchemaConsole\Command\ListAllSchemasCommand;
use Jobcloud\SchemaConsole\SchemaRegistryApi;
use GuzzleHttp\Client;

$client = new Client(
    [
        'base_uri' => 'url-to-your-schema-api',
        //'auth' => ['schema-username', 'schema-password']
    ]
);
$schemaRegistryApi = new SchemaRegistryApi($client);

$console = new Application();
$console->add(new ListAllSchemasCommand($schemaRegistryApi));

或者您也可以通过服务提供者注册它们

<?php

use Jobcloud\SchemaConsole\ServiceProvider\CommandServiceProvider;
use Pimple\Container;

$container = new Container();
$container->register(new CommandServiceProvider());

注意:要使用服务提供者,您需要在容器中设置以下内容

  • 或者 kafka.schema.registry.client,即guzzle客户端,或者可以选择性地设置 kafka.schema.registry.url
  • 如果您需要使用基本认证,需要设置 kafka.schema.registry.usernamekafka.schema.registry.password