PHPackages                             ipunkt/laravel-rabbitmq - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ipunkt/laravel-rabbitmq

Abandoned → [enqueue/enqueue](/?search=enqueue%2Fenqueue)ArchivedLibrary

ipunkt/laravel-rabbitmq
=======================

This is a starter package for laravel

0.3.0(8y ago)56022[4 issues](https://github.com/ipunkt/laravel-rabbitmq/issues)MITPHPPHP &gt;=7.0.0

Since Nov 20Pushed 7y ago3 watchersCompare

[ Source](https://github.com/ipunkt/laravel-rabbitmq)[ Packagist](https://packagist.org/packages/ipunkt/laravel-rabbitmq)[ RSS](/packages/ipunkt-laravel-rabbitmq/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (10)Used By (0)

Deprecated
==========

[](#deprecated)

This package is abandoned. Please consider switching to enqueue with its laravel implementation: [https://github.com/php-enqueue/enqueue-dev/blob/master/docs/laravel/quick\_tour.md](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/laravel/quick_tour.md)

RabbitMQ for Laravel
====================

[](#rabbitmq-for-laravel)

We provide a separate package for the use of [RabbitMQ](https://www.rabbitmq.com) because we want to use it for communication between microservices, written in any language. The existing packages are bound to laravel so we have the whole data - with class names and so on - within the message body. Our package sends only the raw data through RabbitMQ.

[![Latest Stable Version](https://camo.githubusercontent.com/0a827361617845351809fd2f18815f96758746ff628d57443ab8a43db2b3f519/68747470733a2f2f706f7365722e707567782e6f72672f6970756e6b742f6c61726176656c2d7261626269746d712f762f737461626c652e737667)](https://packagist.org/packages/ipunkt/laravel-rabbitmq) [![Latest Unstable Version](https://camo.githubusercontent.com/781c69fe046969feff52d8f6db091aab4ba8026c13ef07b9112c54a1844c1164/68747470733a2f2f706f7365722e707567782e6f72672f6970756e6b742f6c61726176656c2d7261626269746d712f762f756e737461626c652e737667)](https://packagist.org/packages/ipunkt/laravel-rabbitmq) [![License](https://camo.githubusercontent.com/7ec00835aa12f10a56468e6f6350119f603e3796f712e8b257f741aa3cd02c4a/68747470733a2f2f706f7365722e707567782e6f72672f6970756e6b742f6c61726176656c2d7261626269746d712f6c6963656e73652e737667)](https://packagist.org/packages/ipunkt/laravel-rabbitmq) [![Total Downloads](https://camo.githubusercontent.com/044013b7992940da9a7f7a91066275b5966ebdd0573eb3568f5daadbe80fc91f/68747470733a2f2f706f7365722e707567782e6f72672f6970756e6b742f6c61726176656c2d7261626269746d712f646f776e6c6f6164732e737667)](https://packagist.org/packages/ipunkt/laravel-rabbitmq)

This package provides the sending part as well as the listener part. The sending part sends synchronously to the message queue. The listener maps routing keys to an event listener configured.

Branch info
-----------

[](#branch-info)

The master branch is currently for laravel 5.6+. Use the `5.4` branch for laravel &lt;= 5.5 This is necessary because laravel 5.6 changed the logging interfaces.

Quickstart
----------

[](#quickstart)

```
composer require ipunkt/laravel-rabbitmq

```

We support package auto-discovery for laravel, so you are ready to use the package.

Installation
------------

[](#installation)

Add to your composer.json following lines

```
"require": {
	"ipunkt/laravel-rabbitmq": "*"
}

```

You can publish all provided files by typing `php artisan vendor:publish` and select to package provider (or one of the provided tags - but be careful, tags are global).

Configuration
-------------

[](#configuration)

In `config/laravel-rabbitmq.php` is the configuration for the usable queues on RabbitMQ. We do not use any of the values configured in the laravel-shipped `config/queues.php`.

```
'YOUR-QUEUE-IDENTIFIER' => [
	'host' => 'YOUR-RABBITMQ-HOST',
	'port' => 5672,
	'user' => 'guest',
	'password' => 'guest',
	'name' => '',
	'durable' => false,
	'exchange' => [
		'exchange' => 'YOUR-EXCHANGE-NAME',
		'type' => 'YOUR-EXCHANGE-TYPE',
		'passive' => false,
		'durable' => false,
		'auto_delete' => false,
		'internal' => false,
		'nowait' => false,
		'arguments' => null,
		'ticket' => null,
	],
	'bindings' => [
		//  key => event name
		// ROUTING-KEY maps to an LARAVEL-EVENT-CLASS-NAME
	],
],
'logging' => [
	'enable' => false,
	/**
	 * Set this to false if you do not wish to log Exceptions or Throwables from `rabbitmq:listen`
	 */
	'event-errors' => true,
	'queue-identifier' => 'default',
	'extra-context' => [],
],
```

Usage
-----

[](#usage)

### Publishing a Message

[](#publishing-a-message)

Within your controller oder console command you need our `RabbitMQ` class instance:

```
$rabbitMQ = new \Ipunkt\LaravelRabbitMQ\RabbitMQ();// or from DI container
$rabbitMQ->onQueue('YOUR-QUEUE-IDENTIFIER') // Queue Identifier has to be configured within the laravel-rabbitmq.php
	->data(['users' => $users]) // anything, gets json_encoded
	->publish('ROUTING-KEY'); // publish to a routing key, the listener is subscribed to
```

### Subscribing for Messages

[](#subscribing-for-messages)

For subscribing we provide an artisan command:

```
php artisan rabbitmq:listen YOUR-QUEUE-IDENTIFIER
```

We suggest the message sender creates the exchange. If you do it the other way around the listener can create the exchange too. You need to add the command flag `--declare-exchange` to the `rabbitmq:listen` command.

Within the configuration `bindings` has routing keys configured with a 1:1 mapping to a laravel event (`php artisan make:event ...`). This event gets the message data as constructor parameter.

Then you can have one or more listener (`php artisan make:listen ...`) - defined in your EventListener. And voila everything works fine.

We suggest running the `rabbitmq:listen` command with a [supervisor](https://laravel.com/docs/5.5/queues#supervisor-configuration) backed container like the [queue:work](https://laravel.com/docs/5.5/queues#running-the-queue-worker) command shipped with laravel.

#### Receive routing keys in event data

[](#receive-routing-keys-in-event-data)

If a binding with placeholder is used it can be necessary to parse the routing key.

To receive the routing key which triggered the Event to be thrown implement `Ipunkt\LaravelRabbitMQ\TakesRoutingKey`with your event.

To receive the values of the placeholders in your event binding matching the routing key which triggered the Event to be thrown implement `Ipunkt\LaravelRabbitMQ\TakesRoutingMatches`

#### Persistent messages

[](#persistent-messages)

Setting the `durable` for a queue will cause the queue to be created durable. This means it will continue to exist - and receive messages - when `rabbitmq:listen` is not running. To take advantage of this fact `name` should also be set to a string identifying the microservice. This will cause the queue to be named instead of anonymous so running `rabbitmq:listen` will actually reconnect to the queue and process all messages received by it.

Setting `durable` also enables consumer confirmation for messages. This means a message is only deleted from the queue after it is confirmed. This is currently done by returning `true` or `false` from the EventHandler. Returning `true` acknowledges the message as done
Returning `false` acknowledges the message as not processed but does not concern this service so delete anyway Returning anything else including the default `null` or having an exception escalate outside the handler will not acknowledge the message and have it return to the queue.

Note the rabbitmq note on this mode of durability:

---

##### Note on message persistence

[](#note-on-message-persistence)

Marking messages as persistent doesn't fully guarantee that a message won't be lost. Although it tells RabbitMQ to save the message to disk, there is still a short time window when RabbitMQ has accepted a message and hasn't saved it yet. Also, RabbitMQ doesn't do fsync(2) for every message -- it may be just saved to cache and not really written to the disk. The persistence guarantees aren't strong, but it's more than enough for our simple task queue. If you need a stronger guarantee then you can use publisher confirms.

---

### Logging

[](#logging)

If logging is set to true then a MessageHandler is added to the laravel monolog instance which sends messages to the given exchange. If `extra-context` is set then the content will be added to every messages context. Use case for this is to add a `'service' => 'currentmicroservice'` info to all messages to identify which service the message is from. Unless `event-errors` is false Exceptions or Throwables caught in `rabbitmq:listen` are forwarded to the laravel logger.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance4

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~56 days

Recently: every ~80 days

Total

9

Last Release

2637d ago

Major Versions

0.3.0 → 5.4.x-dev2018-06-19

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4946056?v=4)[Robert Kummer](/maintainers/rokde)[@rokde](https://github.com/rokde)

---

Tags

deprecated

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ipunkt-laravel-rabbitmq/health.svg)

```
[![Health](https://phpackages.com/badges/ipunkt-laravel-rabbitmq/health.svg)](https://phpackages.com/packages/ipunkt-laravel-rabbitmq)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[laravel/jetstream

Tailwind scaffolding for the Laravel framework.

4.1k19.8M136](/packages/laravel-jetstream)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
