Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Kafka Laravel Package

mateusjunges/laravel-kafka

Laravel Kafka makes it easy to produce and consume Kafka messages in Laravel with a clean, expressive API and improved testability. Build producers and consumers quickly, integrate with your app workflows, and avoid painful Kafka testing setups.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Event-Driven Architecture: Enables seamless integration of Kafka for real-time event publishing/consuming (e.g., order processing, notifications, analytics pipelines).
  • Decoupled Microservices: Facilitates communication between Laravel services and other systems (e.g., payment processors, third-party APIs) via Kafka topics.
  • Asynchronous Workflows: Replaces synchronous HTTP calls or queues for high-throughput tasks (e.g., batch processing, user activity tracking).
  • Testing & Observability: Built-in fake/testing utilities reduce flakiness in CI/CD pipelines and simplify debugging (e.g., assertPublishedTimes, shouldReceiveMessages).
  • Schema Evolution: Supports Avro deserializers for backward-compatible schema changes, critical for long-lived systems.
  • Build vs. Buy: Avoids reinventing Kafka integration (e.g., manual librdkafka bindings) while maintaining Laravel’s idiomatic syntax.
  • Roadmap Priorities:
    • Phase 1: Replace legacy RabbitMQ/Redis queues with Kafka for scalability.
    • Phase 2: Adopt Kafka Streams for real-time aggregations (e.g., fraud detection).
    • Phase 3: Migrate from direct HTTP APIs to event-driven workflows (e.g., partner integrations).

When to Consider This Package

Adopt When:

  • Your Laravel app requires high-throughput, low-latency messaging (e.g., >10K messages/sec).
  • You need durable, fault-tolerant event storage (Kafka retains messages for days/weeks).
  • Your team is already using Laravel 12+ and PHP 8.2+ (avoids polyfill overhead).
  • You want Laravel-native syntax for Kafka (e.g., Kafka::publish()->onTopic()->send()) over raw librdkafka.
  • Testing is a priority: Fake consumers/producers simplify unit/integration tests (e.g., mocking Kafka in CI).
  • You’re migrating from RabbitMQ, Redis, or direct HTTP to a more scalable backbone.

Look Elsewhere If:

  • Your team lacks Kafka infrastructure (brokers, Zookeeper/KRaft, schema registry).
  • You need exactly-once processing (requires Kafka 3.0+ + idempotent producers; this package abstracts but doesn’t enforce it).
  • Your use case is simple pub/sub (e.g., <1K messages/day): Laravel’s built-in queues may suffice.
  • You’re constrained by PHP extensions (e.g., rdkafka installation is blocked in your environment).
  • You need multi-protocol support (e.g., MQTT, WebSockets) alongside Kafka.

How to Pitch It (Stakeholders)

For Executives:

"This package lets us leverage Kafka—an industry-standard, scalable messaging system—without hiring specialized engineers. It integrates natively with Laravel, so our backend team can adopt event-driven architecture to:

  • Decouple services: Replace direct API calls between teams with Kafka topics (e.g., orders → inventory → notifications).
  • Scale effortlessly: Handle 10x more traffic than Redis queues without manual sharding.
  • Future-proof: Support real-time analytics, microservices, and third-party integrations with minimal rework. We’ll start with a pilot (e.g., order processing) and measure cost savings from reduced API timeouts and improved reliability. The MIT license and active maintenance mean no vendor lock-in."

For Engineering:

"This is a drop-in replacement for manual Kafka integration with Laravel’s familiar syntax. Key wins:

  • Fluent API: Chain methods like Kafka::publish()->onTopic()->withHeaders()->send().
  • Testing superpowers: Fake Kafka in PHPUnit with Kafka::fake() and assert message counts/headers.
  • Avro support: Handle schema evolution without breaking consumers (critical for long-lived systems).
  • Async by default: Use the async producer for high-throughput workloads (avoids blocking). Downsides: Requires rdkafka extension (but we can containerize it) and assumes Kafka brokers are already provisioned. Let’s prototype with the [order service] to validate performance gains over queues."

For DevOps/SRE:

"This package abstracts Kafka’s complexity behind a Laravel facade, but we’ll need to:

  1. Deploy Kafka brokers (or use a managed service like Confluent Cloud).
  2. Configure schema registry (for Avro; can start with JSON if needed).
  3. Monitor lag/consumption (Kafka-specific metrics like kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec). Tradeoff: More moving parts, but we avoid custom scripts for message serialization/deserialization."
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope