PHPackages                             kontoulis/rabbitmq-laravel - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. kontoulis/rabbitmq-laravel

ActiveLibrary[Queues &amp; Workers](/categories/queues)

kontoulis/rabbitmq-laravel
==========================

RabbitMQ Broker for Laravel

2.1.10(8y ago)151.2k6MITPHPPHP &gt;=5.3.0

Since Oct 3Pushed 8y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (9)Used By (0)

RabbitMQLaravel
===============

[](#rabbitmqlaravel)

[![Latest Stable Version](https://camo.githubusercontent.com/2c1d12d9ee155461c9a39ce076ee5901aeaae28e526295fe9de259f3b45fa075/68747470733a2f2f706f7365722e707567782e6f72672f6b6f6e746f756c69732f7261626269746d712d6c61726176656c2f762f737461626c65)](https://packagist.org/packages/kontoulis/rabbitmq-laravel)[![Latest Unstable Version](https://camo.githubusercontent.com/bbf199189482e182cd8854f22f6b00411780f3420c524b46a98e05862f6d7439/68747470733a2f2f706f7365722e707567782e6f72672f6b6f6e746f756c69732f7261626269742d6d616e616765722f762f756e737461626c65)](https://packagist.org/packages/kontoulis/rabbitmq-laravel)[![License](https://camo.githubusercontent.com/584f5d31240a7b9b359c508d0e41689b45833273ed66970afe63d76d9b799132/68747470733a2f2f706f7365722e707567782e6f72672f6b6f6e746f756c69732f7261626269742d6d616e616765722f6c6963656e7365)](https://packagist.org/packages/kontoulis/rabbitmq-laravel)

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

[](#installation)

Via Composer

```
$ composer require kontoulis/rabbitmq-laravel
```

Add the Service Provider to config/app.php

```
Kontoulis\RabbitMQLaravel\RabbitMQLaravelServiceProvider::class,
```

Add the RabbitMQ facade to config/app.php

```
'RabbitMQ' => Kontoulis\RabbitMQLaravel\Facades\RabbitMQ::class,
```

Publish the configuration file and edit it if needed in config/rabbitmq-laravel.php

```
$ php artisan vendor:publish
```

Usage
-----

[](#usage)

- Routing Key / Queue Name

The default routing key can be set in config file, or env("APP\_NAME")."\_queue") will be used. Also most methods take argument `$routingKey` which can override the default.

```
RabbitMQ::setRoutingKey("myRoutingKey/queueName");
```

- Exchange

If you don't set an exchange the default `''` exchange will be used. If you set one, make sure the bindings are set in RabbitMQ system. if you are not familiar with exchanges you will probably do not need to set that.

```
RabbitMQ::setExchange("myExchange")'
```

You can use the RabbitMQ facade to do anything as seen in  . Basically, the RabbitMQ facade uses the Broker class which is an extension of AMQPChannel.

- Publishing

```
// Single message

$msg = [
    "key1" => "value1",
    "key2" => "value2"
    ];
RabbitMQ::publishMesssage($msg);

// OR
RabbitMQ::publishMessage($msg, "myRoutingKey");

// Batch publishing

$messages = [
    [ "messsage_1_key1" => "value1",
      "messsage_1_key2" => "value2"
    ],
    [
    "messsage_2_key1" => "value1",
    "messsage_2_key2" => "value2"
    ]
];
RabbitMQ::publishBatch($messages);
// OR
RabbitMQ::publishBatch($messages, "myRoutingKey");
```

- Consuming the Queue

In order to consume the queue, you could either use the AmqpChannel through the Facade, or use a better to manage approach with QueueHandlers. A QueueHandler should extend the Kontoulis\\RabbitMQLaravel\\Handlers\\Handler class and the built-in ListenToQueue method accepts an array of handlers to process the queue message. If more than one handler exists in array, there are some Handler return values that will use the follow up QueueHandlers in cases of failure of the previous. There is also a Kontoulis\\RabbitMQLaravel\\Handlers\\Handler\\DefaultHandler class as example and/or debug handler.

```
namespace Kontoulis\RabbitMQLaravel\Handlers;

use Kontoulis\RabbitMQLaravel\Message\Message;

/**
 * Class DefaultHandler
 * @package Kontoulis\RabbitMQLaravel\Handlers
 */
class DefaultHandler extends Handler{

    /**
     * Tries to process the incoming message.
     * @param Message $msg
     * @return int One of the possible return values defined as Handler
     * constants.
     */

    public function process(Message $msg)
    {
        return $this->handleSuccess($msg);

    }

    /**
     * @param $msg
     * @return int
     */
     protected function handleSuccess($msg)
       {
           var_dump($msg);
           /**
            * For more Handler return values see the parent class
            */
           return Handler::RV_SUCCEED_STOP;
       }
}
```

In order to Listen to the Queue you have to pass an array of Handlers to the method

```
$handlers = ["\\App\\QueueHandlers\\MyHandler"];
\RabbitMQ::listenToQueue($handlers);
```

License
-------

[](#license)

The MIT License (MIT). Please see [LICENCE.md](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% of commits — single point of failure

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 ~137 days

Recently: every ~49 days

Total

7

Last Release

3051d ago

Major Versions

v1.0.4 → v2.0.02017-06-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/31dcb4fd58402de973ea2f3f49187cfbe2d1752b262e89b51479f2e10cc27235?d=identicon)[kontoulis](/maintainers/kontoulis)

---

Top Contributors

[![kontoulis](https://avatars.githubusercontent.com/u/6674486?v=4)](https://github.com/kontoulis "kontoulis (65 commits)")[![verwilst](https://avatars.githubusercontent.com/u/2114993?v=4)](https://github.com/verwilst "verwilst (5 commits)")

---

Tags

laravelphprabbitmqlaravelrabbitmq

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[bschmitt/laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages

2752.3M7](/packages/bschmitt-laravel-amqp)[mookofe/tail

RabbitMQ and PHP client for Laravel and Lumen that allows you to add and listen queues messages just simple

5552.5k](/packages/mookofe-tail)[convenia/pigeon

3233.0k](/packages/convenia-pigeon)[kunalvarma05/laravel-rabbitmq

Work with RabbitMQ in Laravel.

1853.7k](/packages/kunalvarma05-laravel-rabbitmq)

PHPackages © 2026

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