# Laravel Kafka, producing and consuming Kafka messages from a Laravel application

> mateusjunges/laravel-kafka is a MIT licensed package that gives Laravel applications a producer and consumer API for Kafka, written by a maintainer who set out to fix two specific complaints: that other packages have poor usage syntax, and that testing Kafka code in PHP is painful. Documentation lives on its own site, and releases ship every few weeks.

**mateusjunges/laravel-kafka** — Use Kafka Producers and Consumers in your laravel app with ease!

- Repository: https://github.com/mateusjunges/laravel-kafka
- Website: https://laravelkafka.com
- Stars: 736 · Forks: 107
- Language: PHP
- License: MIT
- Published: 2026-10-21 · Updated: 2026-10-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/mateusjunges-laravel-kafka

## The problem the author set out to fix

The README opens with a question and then an explanation, and the explanation is the best available statement of what this package is for.

Do you use Kafka in your laravel projects? The author answers that all the packages he had seen, including some built by himself, did not provide a nice usage syntax, and that even where the syntax was fine, the test process with these packages was very painful.

Those are two distinct problems and they are worth separating, because they are the reason a Laravel-specific wrapper exists at all. The first is ergonomic. A raw Kafka client exposes topics, partitions, offsets, consumer groups, serializers and acknowledgements, and using that from a Laravel controller or job means writing a layer yourself that connects the broker to the framework's service container, its configuration and its logging. The second is testing, and it is the harder one to solve.

Testing a Kafka consumer in PHP is awkward because a Kafka consumer is inherently about messages arriving at an arbitrary time from a broker that has to be running. There is no natural way to say this is the message, run the handler, and assert on the result, because the message arrives through a network poller rather than through a function call. Every PHP Kafka package has to solve that, and most solve it badly.

So the package's scope is producing and consuming Kafka messages in Laravel projects with a syntax that fits, and with a test story that is not painful. The documentation is hosted separately at laravelkafka.com, which is where the details of the API live, and the README's role is mostly to point there.

The package is published on Packagist as mateusjunges/laravel-kafka, is MIT licensed, and the last push was on 2026-10-15 with v2.13.0 released on 2026-10-07, v2.12.1 on 2026-09-29 and v2.12.0 on 2026-09-28. A release roughly every week or two is the cadence of a package with real usage and a responsive maintainer.

## The repository layout and the tooling it implies

The top level of the repository is a conventional PHP package layout with a few entries that tell you about the project's practices.

There is a src/ directory holding the implementation, a config/ directory for the package configuration that Laravel publishes, a tests/ directory with the suite, and a docs/ directory. Then there is composer.json, the phpunit.xml configuration, a CHANGELOG.md and the LICENSE file.

Three of these files are worth reading for what they say about how the project is maintained. There is a phpunit.xml.bak next to the phpunit.xml, which is the kind of leftover that says a configuration was changed and the old version was kept rather than deleted. There is a pint.json, which is the configuration for Laravel Pint, the code style fixer that is part of the standard Laravel toolchain. And there is a rector.php, which configures Rector, the automated refactoring tool. Having both Pint and Rector configured means the project runs a style pass and an automated upgrade pass, which is how a package keeps up with new framework versions without a large manual diff.

There is a .github/ directory holding the workflows and the contribution guide, and the CI badge in the README points at a run-tests workflow, so the test suite runs on every push. The art/ directory holds the project image and the sponsor badge, and .gitattributes and .gitignore are the usual repository hygiene files.

The docs/ directory is worth a note. Having the documentation in the repository rather than only on the website means the documentation is versioned alongside the code, and it means a reader browsing the repository at a particular tag sees the documentation for that version rather than the current one. The website is generated from it.

Nothing here is unusual, and that is the point: this is a package laid out the way a Laravel package is expected to be laid out, which means the tooling around it, the test harness, the static analysis and the style rules all work with it without special handling.

## Testing, contributing and how the work is funded

The README's testing section is one line, and it names the command:

```bash
composer test
```

The brevity is itself a statement. For a package whose entire premise is that testing Kafka code in PHP should not be painful, the test command being a single obvious entry point is part of the message, and the practical effect is that a contributor can run the suite without learning a bespoke harness.

The contributing side is described in one sentence with a pointer to a guide in the .github directory. The guide being in the .github directory rather than in a docs page is the convention GitHub surfaces automatically when someone opens an issue or a pull request, so the guidance appears exactly where someone needs it.

The funding model is explicit. The README has a section asking for sponsorship, with a badge linking to the GitHub sponsors page, and the author links his personal site and his accounts on Twitter and Bluesky. The framing is that if the package helped you in any way, you can sponsor the work. That is a single-maintainer open source project, and the sponsorship link is the mechanism by which the maintenance burden is paid.

The credits section names Mateus Junges, the author, and the package is published under his name on Packagist. Combined with the personal site and the social accounts, this is a project where one person is clearly responsible for it, which is worth weighing when you are choosing a dependency for something your own application depends on. It is not a criticism of the code. It is a practical point about where the bus factor is, and the answer here is that the bus factor is one, which is a reason to read the source rather than only the documentation.

The MIT licence is the other thing to check for a package like this, and it is as permissive as open source gets: use it, modify it, ship it inside a commercial product, with no obligation beyond keeping the notice. The licence file is at the top level of the repository and the link points at the standard text.

## How it fits against the alternatives

The alternatives divide into three kinds, and the choice is mostly about how much Kafka you actually need.

The first is using Kafka's own PHP client directly. The official client is mature and complete, and for a project that only produces messages from one place, wrapping it in a Laravel package may be one layer too many. The cost of the direct route is that you build the integration yourself: configuration, container binding, logging, and a testing story. For a small integration that is often the right trade.

The second is not using Kafka. Laravel's queue system has drivers for Redis, database, SQS, Beanstalk and others, and if the requirement is decoupled background work rather than a high-throughput event log, a queue driver is a much smaller operational commitment. Kafka is a log with retention and replay and partition-level ordering, and if you do not need those properties, the complexity is not buying you anything. This package cannot change that, and it is worth being honest that choosing it does not make Kafka cheap.

The third is other Laravel or PHP Kafka wrappers, and here the README's own reasoning applies. The author says the packages he had seen had poor usage syntax, or painful testing. That is a claim about a category rather than about named competitors, which means you should check the current state of the alternatives yourself rather than take it as current, since packages change and new ones appear.

The case for this package is the combination of Laravel conventions with a test harness that works. A package that binds the producer and consumer through the service container, reads its configuration from a published config file, and lets you assert on a message without running a broker is doing real work, and the testability part is the one that is hard to reproduce in your own code.

The case against is the single-maintainer risk and the maturity of the wrapper itself. The package is on its second major version with weekly releases, which suggests active development, but a wrapper is also a layer that can lag behind the client it wraps, and a Kafka client upgrade that changes a constructor signature is a break for the wrapper before it is one for you. Pinning the version and reading the CHANGELOG before an upgrade is the sensible habit with any package of this kind.

The honest summary is that this is a well-scoped convenience layer for a specific framework, maintained attentively by one person, with the documentation in the repository and the tests runnable with a single command. If you have decided you want Kafka, it removes the tedious parts of the integration. If you have not, nothing in this package will make that decision easier.

## Conclusion

Adopt laravel-kafka if you run a Laravel application that produces or consumes Kafka messages and you want the framework conventions applied to the client rather than a raw library dropped into your code. Skip it if your messaging needs are simple enough for a queue driver Laravel already ships, since Kafka has a real operational cost that a package cannot remove. Verify first by installing the package, pointing the config at a local broker, and running the package test suite with composer test to see how the test harness handles Kafka.

## FAQ

### What is laravel-kafka?

It is a MIT licensed PHP package that provides a way of producing and consuming Kafka messages in Laravel projects, with a usage syntax meant to fit the framework rather than a raw client call. The package is published on Packagist as mateusjunges/laravel-kafka and is documented at laravelkafka.com.

### Why did the author write laravel-kafka?

The README says that all the Kafka packages the author had seen, including some he had built himself, did not provide a nice usage syntax, and that the test process with those packages was very painful. The package is intended to address both, with the test story being the harder of the two problems to solve in PHP.

### How do I run the laravel-kafka test suite?

With composer test, as the README states in its testing section. The suite runs through a GitHub Actions workflow named run-tests, and the repository carries a phpunit.xml alongside a Pint configuration for code style and a Rector configuration for automated refactoring.

### Where is the laravel-kafka documentation?

On a separate site at laravelkafka.com, and the documentation source is kept in the docs/ directory of the repository, so it is versioned alongside the code rather than only on the website.

### How is laravel-kafka licensed and maintained?

It is MIT licensed, with the terms in the LICENSE file. It is a single-maintainer project by Mateus Junges, who asks for GitHub sponsorship, and the release history shows v2.12.0, v2.12.1 and v2.13.0 in late September and October 2026.

## Sources

- [License: MIT](https://github.com/mateusjunges/laravel-kafka/blob/master/LICENSE)
- [mateusjunges/laravel-kafka on GitHub](https://github.com/mateusjunges/laravel-kafka)
- [Project website](https://laravelkafka.com)
- [README](https://github.com/mateusjunges/laravel-kafka/blob/master/README.md)
- [Releases](https://github.com/mateusjunges/laravel-kafka/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/mateusjunges-laravel-kafka
