{"id":15063284,"url":"https://github.com/geekcell/kafka-symfony-bundle","last_synced_at":"2025-04-10T10:42:48.065Z","repository":{"id":65191640,"uuid":"585849492","full_name":"geekcell/kafka-symfony-bundle","owner":"geekcell","description":"An opinionated Symfony bundle for a painless integration of Apache Kafka.","archived":false,"fork":false,"pushed_at":"2023-01-09T16:20:06.000Z","size":78,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-05T22:17:12.866Z","etag":null,"topics":["apache-kafka","avro","avro-schema","avro-schema-registry","php","php8","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"https://www.geekcell.io","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geekcell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2023-01-06T08:43:54.000Z","updated_at":"2024-08-02T14:40:49.000Z","dependencies_parsed_at":"2023-01-09T20:52:47.120Z","dependency_job_id":null,"html_url":"https://github.com/geekcell/kafka-symfony-bundle","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcell%2Fkafka-symfony-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcell%2Fkafka-symfony-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcell%2Fkafka-symfony-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geekcell%2Fkafka-symfony-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geekcell","download_url":"https://codeload.github.com/geekcell/kafka-symfony-bundle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199852,"owners_count":21063773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-kafka","avro","avro-schema","avro-schema-registry","php","php8","symfony","symfony-bundle"],"created_at":"2024-09-24T23:54:28.732Z","updated_at":"2025-04-10T10:42:48.048Z","avatar_url":"https://github.com/geekcell.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony Bundle for Apache Kafka\n\nAn opinionated Symfony bundle for a painless integration of [Apache Kafka](https://kafka.apache.org/).\n\n## Requirements\n\n- PHP 8 or higher\n- [php-rdkafka](https://github.com/arnaud-lb/php-rdkafka) extension installed\n- Apache Kafka broker\n- Confluent [Schema Registry](https://github.com/confluentinc/schema-registry) for Kafka\n\n## Installation\n\nTo use this bundle, require it in Composer\n\n```bash\ncomposer require geekcell/kafka-bundle\n```\n\n## Quickstart\n\nInherit from `Record` to define records you want to send to Kafka.\n\n```php\nuse GeekCell\\KafkaBundle\\Record;\nuse FlixTech\\AvroSerializer\\Objects\\Schema;\n\nclass OrderDto extends Record\n{\n    public int $id;\n    public int $productId;\n    public int $customerId;\n    public int $quantity;\n    public float $total;\n    public string $status = 'PENDING';\n\n    public function getKey(): ?string\n    {\n        // Nullable; if provided it will be used as message key\n        // to preserve message ordering.\n        return sprintf('order_%s', $this-\u003eid);\n    }\n\n    protected function withFields(RecordType $root): Schema\n    {\n        // See for examples:\n        // https://github.com/flix-tech/avro-serde-php/tree/master/test/Objects/Schema\n        $root\n            -\u003efield('id', Schema::int())\n            -\u003efield('productId', Schema::int())\n            -\u003efield('customerId', Schema::int())\n            -\u003efield('quantity', Schema::int())\n            -\u003efield('total', Schema::float())\n            -\u003efield(\n                'status', \n                Schema::enum()\n                    -\u003ename('OrderStatusEnum')\n                    -\u003esymbols(...['PENDING', 'PAID', 'SHIPPED', 'CANCELLED'])\n                    -\u003edefault('PENDING'),\n            );\n\n        return $root;\n    }\n}\n```\n\nCreate an event, which implements the `Event` contract and returns the above record as _subject_.\n\n```php\nuse GeekCell\\KafkaBundle\\Contracts\\Event;\n\nclass OrderPlacedEvent implements Event\n{\n    public function __construct(\n        private OrderDto $orderDto,\n    ) {\n    }\n\n    public function getSubject(): Record\n    {\n        return $this-\u003eorderDto;\n    }\n}\n```\n\nIf you dispatch `Event` via the standard Symfony event dispatcher, it will be automatically be serialized into Avro format, registered, send to Kafka based on your configuration.\n\n```php\n$this-\u003eeventDispatcher-\u003edispatch(new OrderPlacedEvent($orderDto));\n```\n\n## Bundle Configuration Example\n\n```yaml\ngeek_cell_kafka:\n    avro:\n        schema_registry_url: 'http://schemaregistry:8081'\n        schemas:\n            defaults:\n                namespace: 'com.acme.avro'\n    events:\n        lookup: # Look up events in the following directories\n            - 'src/Event'\n\n    kafka:\n        brokers: 'broker:9091,broker:9092'\n        global:\n            # Global config params for librdkafka (not pre-validated)\n            # https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md#global-configuration-properties\n        topic:\n            # Topic config params for librdkafka (not pre-validated)\n            # https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md#topic-configuration-properties\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekcell%2Fkafka-symfony-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeekcell%2Fkafka-symfony-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekcell%2Fkafka-symfony-bundle/lists"}