PHPackages                             alifcoder/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. alifcoder/laravel-rabbitmq

ActiveLibrary

alifcoder/laravel-rabbitmq
==========================

Simple RabbitMQ client for Laravel with pub/sub and RPC-style request/response support.

v1.0.3(today)09↑2566.7%MITPHPPHP ^8.1

Since Jul 30Pushed todayCompare

[ Source](https://github.com/alifcoder/laravel-rabbitmq)[ Packagist](https://packagist.org/packages/alifcoder/laravel-rabbitmq)[ RSS](/packages/alifcoder-laravel-rabbitmq/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (5)Used By (0)

laravel-rabbitmq
================

[](#laravel-rabbitmq)

Simple RabbitMQ client for Laravel with pub/sub and RPC-style request/response support.

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

[](#installation)

```
composer require alifcoder/laravel-rabbitmq
```

The service provider and `Rabbit` facade are auto-discovered. Publish the config:

```
php artisan vendor:publish --tag=rabbitmq-config
```

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

[](#configuration)

`config/rabbitmq.php`:

KeyEnv varDefault`host``RABBITMQ_HOST``localhost``port``RABBITMQ_PORT``5672``user``RABBITMQ_USER``guest``password``RABBITMQ_PASSWORD``guest``rpc_timeout``RABBITMQ_RPC_TIMEOUT``10` (seconds)`default_queue``RABBITMQ_DEFAULT_QUEUE``msgs`What the package provides vs. what you write
--------------------------------------------

[](#what-the-package-provides-vs-what-you-write)

`Alif\LaravelRabbitmq\Client` is a thin, low-level primitive: connection/channel management, `publish()`, `request()->getResult()`, and a `consume(queue, callback)->wait()` pair where you get the raw `PhpAmqpLib\Message\AMQPMessage` and are responsible for acknowledging it yourself.

There's no handler registry, method dispatch, or dead-letter routing built into the package — that's application logic, not library logic. [`examples/`](examples) shows one way to build it: a `RabbitHandler` class (dispatched to by method name, with `BaseDto` auto-hydrating typed parameters from the message `params`) plus a `RabbitConsume` command that wires it up, RPC replies included. Copy it into your project and adjust it to taste — see "Consuming" below.

Usage
-----

[](#usage)

### `rabbit()` helper (recommended)

[](#rabbit-helper-recommended)

```
// Publish (fire-and-forget)
rabbit('createUser', ['email' => 'a@b.com', 'name' => 'Ada'])->publish();

// RPC request (wait for a reply)
$result = rabbit('getUser', ['id' => 5])->getResult();

// Optionally target a queue other than `default_queue`
rabbit('createUser', ['email' => 'a@b.com', 'name' => 'Ada'], queue: 'pos')->publish();
```

`rabbit(string $method, array $params = [], ?string $queue = null): Rabbit` returns a `Alif\LaravelRabbitmq\Rabbit` instance — call `->publish()` or `->getResult()` on it.

### Facade

[](#facade)

The same operations are available on the `Rabbit` facade, which proxies the underlying `Alif\LaravelRabbitmq\Client` singleton directly:

```
use Alif\LaravelRabbitmq\Facades\Rabbit;

Rabbit::publish(method: 'createUser', params: ['email' => 'a@b.com', 'name' => 'Ada']);

$result = Rabbit::request(method: 'getUser', params: ['id' => 5])->getResult();
```

Both throw `RuntimeException` if an RPC request gets no reply within `rpc_timeout` seconds.

### Consuming

[](#consuming)

```
use Alif\LaravelRabbitmq\Client;
use PhpAmqpLib\Message\AMQPMessage;

$client->consume('erp', function (AMQPMessage $message) {
    $message->ack();

    $data = json_decode($message->getBody(), true);
    // ... do something with $data['method'] / $data['params'] ...

    // if the message was sent via request()->getResult(), reply to it:
    if ($message->has('reply_to') && $message->has('correlation_id')) {
        $message->getChannel()->basic_publish(
            new AMQPMessage(json_encode($result), ['correlation_id' => $message->get('correlation_id')]),
            '',
            $message->get('reply_to')
        );
    }
})->wait();
```

- You choose the queue per call — nothing is read from `config('rabbitmq.queues')`.
- You ack (or nack/reject) the message yourself; the package won't do it for you.
- `wait()` blocks and runs the consume loop; call it once after registering every `consume()` callback you need.

[`examples/Console/Commands/RabbitConsume.php`](examples/Console/Commands/RabbitConsume.php) wraps this in a full `rabbit:consume` artisan command — method/DTO dispatch to a `RabbitHandler`, RPC replies, and per-message error handling included. Copy it into your project:

```
cp vendor/alifcoder/laravel-rabbitmq/examples/Console/Commands/RabbitConsume.php app/Console/Commands/
cp vendor/alifcoder/laravel-rabbitmq/examples/RabbitHandler.php app/Rabbitmq/RabbitHandler.php
```

Laravel auto-discovers commands under `app/Console/Commands/`, so `php artisan rabbit:consume`works immediately once it's there — no registration needed.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance100

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

4

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/94315908?v=4)[Shukhrat Yuldashev](/maintainers/alifcoder)[@alifcoder](https://github.com/alifcoder)

---

Top Contributors

[![khamdullaevuz](https://avatars.githubusercontent.com/u/81905341?v=4)](https://github.com/khamdullaevuz "khamdullaevuz (6 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M325](/packages/laravel-horizon)[illuminate/queue

The Illuminate Queue package.

20432.6M1.7k](/packages/illuminate-queue)[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5752.3M21](/packages/directorytree-ldaprecord-laravel)

PHPackages © 2026

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