Download the PHP package batatahub-tech/laravel-rabbitmq without Composer
On this page you can find all versions of the php package batatahub-tech/laravel-rabbitmq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download batatahub-tech/laravel-rabbitmq
More information about batatahub-tech/laravel-rabbitmq
Files in batatahub-tech/laravel-rabbitmq
Package laravel-rabbitmq
Short Description Full RabbitMQ package for Laravel: manage exchanges, queues, bindings, publish and consume messages
License MIT
Informations about the package laravel-rabbitmq
Laravel RabbitMQ
A lightweight, fluent RabbitMQ integration for Laravel. Manage exchanges, queues, and bindings; publish and consume messages; generate consumer classes; and configure multiple connections.
Supports Laravel 10/11/12 and PHP 8.1+ (uses php-amqplib/php-amqplib v3).
Features
- Manage exchanges, queues, and bindings via a fluent service
- Publish JSON messages easily
- Consume via Artisan or programmatically
- Multiple connections out of the box
- Artisan generator for consumer classes with publishable stub
- Configuration publishing
Installation
The service provider is auto-discovered. No manual registration needed.
Publish configuration and stub (optional)
Configuration
After publishing, tweak config/rabbitmq.php. You can define multiple connections and map consumers to them.
Environment variables you may set in .env:
Generating Consumers
Generate a consumer class (you can pass nested paths using /):
Generated file will live under app/RabbitMQ/Consumers/... with namespace App\RabbitMQ\Consumers.
Example handler with manual ack/nack control:
Notes:
- If you prefer broker auto-ack, set
'noAck' => truefor the consumer in config; then you should not callack(). - With
'noAck' => false(default), you must callack()ornack()in the handler.
Consuming via Artisan
Consume all configured consumers for a connection:
Consume only a specific queue for that connection:
What happens:
- The command looks up consumers in
config/rabbitmq.phpfiltered by{connection}and optional{queue}. - For each match, it creates the handler and starts consuming.
- Your handler is called for each message; you control
ack()/nack()unlessnoAck=true.
Publishing Messages
Use the RabbitMQService via constructor injection anywhere in your app. Messages are published as JSON (content_type: application/json).
Programmatic Consumption
You can also consume without the Artisan command:
Version Compatibility
| Laravel | PHP | Package |
|---|---|---|
| 12.x | 8.1+ | ^1.0 |
| 11.x | 8.1+ | ^1.0 |
| 10.x | 8.1+ | ^1.0 |
Relies on php-amqplib/php-amqplib:^3.0.
FAQ
-
How are messages encoded?
- Arrays are JSON-encoded.
content_typeis set toapplication/json.
- Arrays are JSON-encoded.
-
Who controls ack/nack?
- You do, inside your consumer handler, unless you set
noAck=truein the config to enable broker auto-ack.
- You do, inside your consumer handler, unless you set
- Can I customize the consumer stub?
- Yes. Publish the stub with the
stubstag, edit it in your app, and the generator will use your customized version.
- Yes. Publish the stub with the
License
MIT
All versions of laravel-rabbitmq with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/console Version ^10.0|^11.0|^12.0
php-amqplib/php-amqplib Version ^3.0