PHPackages                             heismehrab/php-rabbitmq-x - 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. heismehrab/php-rabbitmq-x

ActiveLibrary

heismehrab/php-rabbitmq-x
=========================

1.0.2(4y ago)38MITPHP

Since Jul 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/heismehrab/php-rabbitMQ-x)[ Packagist](https://packagist.org/packages/heismehrab/php-rabbitmq-x)[ RSS](/packages/heismehrab-php-rabbitmq-x/feed)WikiDiscussions master Synced today

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

php-rabbitMQ-x package
======================

[](#php-rabbitmq-x-package)

[![Total Downloads](https://camo.githubusercontent.com/8403738aa5a3cc71e8cdb955fe9455bae730463ac57ecffb91b06d0d8c51a39f/68747470733a2f2f706f7365722e707567782e6f72672f686569736d65687261622f7068702d7261626269746d712d782f642f746f74616c2e737667)](https://packagist.org/packages/heismehrab/php-rabbitmq-x)[![Latest Stable Version](https://camo.githubusercontent.com/cce2441eed43f48bed4e41df68d686dfaee226ff9da797cfd24b832d8b2eafa9/68747470733a2f2f706f7365722e707567782e6f72672f686569736d65687261622f7068702d7261626269746d712d782f762f737461626c652e737667)](https://packagist.org/packages/heismehrab/php-rabbitmq-x)[![License](https://camo.githubusercontent.com/70fa198e6ec354ab114572bb6c57f86d8fb669dfb618a655eca12544e304be03/68747470733a2f2f706f7365722e707567782e6f72672f686569736d65687261622f7068702d7261626269746d712d782f6c6963656e73652e737667)](https://packagist.org/packages/heismehrab/php-rabbitmq-x)[![License](https://camo.githubusercontent.com/ac36e9ba34c1e11e2cbc6957747af732451b47710cf944d71454ea2f3eb1f54a/68747470733a2f2f706f7365722e707567782e6f72672f686569736d65687261622f7068702d7261626269746d712d782f636f6d706f7365726c6f636b)](https://packagist.org/packages/heismehrab/php-rabbitmq-x)

This package basically designed to communicate with your Rabbitmq instance to consume/produce messages.

You must be familiar with basic titles of Rabbitmq to understand how this packages works and how it behaves with Rabbitmq processes.

We suggest that you visit the [official website of Rabbitmq](https://rabbitmq.com) if you are not familiar with the whole Rabbitmq cycle, or you can visit [example oriented](https://www.rabbitmq.com/getstarted.html) samples of Rabbitmq if you already familiar with it.

Installation.
-------------

[](#installation)

Before anything, developer has to know that package uses php `>= 7.0` and  ONLY  features of Rabbitmq which supported by the package explains in below:

titlesFeatures/TypesversionQueues`DLX`, `exchange-bindings``0.9.0`, `1.0.0`Exchanges`Fanout`, `direct`, `routing-keys``0.9.0`, `1.0.0`QOS (Fair dispatching)`prefetch-size`, `prefetch-count``0.9.0`, `1.0.0`
install via composer: ```
$ composer require heismehrab/php-rabbitmq-x
```

After installing the package, we need to have a configuration file which the both producer and consumer workers needs it to start the process.

This configuration file keeps the details of all `Rabbitmq authentication`, `Queues`, `Exchanges`, `Dead letter exchanges`, `exchange and queue bindings` and `QOS tuning settings`;

You can see and use the structure of original config file in below:

```
[

    /* ------------------------ RABBITMQ AUTHORIZATION  ------------------------ */
    'host' => '',
    'port' => '',
    'username' => '',
    'password' => '',

    /* ------------------------ RABBITMQ QOS CONFIGURATION ------------------------ */

    /**
     * TRUE will affect on channel,
     * FALSE will affected on consumers.
     */
    'global' => false,

    'prefetch_size' => null,

    /**
     * number of tasks/jobs that comes to channel
     * or picked up by consumers according to *global* (see index global above).
     */
    'prefetch_count' => 5,

    /**
     * An associative array witch defines the
     * exchanges and its related type and queues;
     * array indexes are exchange names and its values (an array of data)
     * is type and queue names.
     *
     * this config affected when you
     * start to work with RabbitMQ.
     *
     * type Fanout: for RabbitMQ instance with fanout exchange.
     *
     * type Direct: for RabbitMQ instance with direct exchange.
     */
    'exchanges' => [
        'default' => [
            'type' => 'fanout',
            'queues' => [
                'Q1' => [], // Without any routing key.
                'Q2' => [] // Without any routing key.
            ],
        ],

        'notifications' => [
            'type' => 'direct',
            'queues' => [
                'Q3' => [ // With routing keys.
                    'high',
                    'low'
                ],

                'Q4' => [ // With routing keys.
                    'high'
                ]
            ]
        ]
    ],

    /* ------------------------ RABBITMQ QUEUE CONFIGURATION ------------------------ */

    /**
     * Queues are place in here,
     * defined queues must be same with declared ones
     * in *exchanges* array (see index exchanges above)
     */
    'queues' => [
        'Q1' => [
            'dead_letter_exchange' => [
                'name' => 'foo', // With exchange.
                'routing_key' => 'key1' // With routing key.
            ]
        ],

        'Q2' => [
            'dead_letter_exchange' => [
                'name' => 'bar', // With exchange.
                'routing_key' => '' // Without routing keys.
            ]
        ],

        'Q3' => [
            'dead_letter_exchange' => [] // Without exchange.
        ],

        'Q4' => [
            'dead_letter_exchange' => [] // Without exchange.
        ]
    ]
];
```

For more examples of the configuration file, you can check the [original file](./src/Config/config.php) which placed in package root directory.

How the package works?
----------------------

[](#how-the-package-works)

When we get an instance of a Producer/Consumer and inject the configuration file into that, the service will start validate the file and then declare the queues, exchanges, etc... which explained in above table; finally we have a configured Rabbitmq instance which is ready to handle messages/tasks.

Examples.
---------

[](#examples)

some samples that describe how a Producer and Consumer works:

#### Producer:

[](#producer)

```
use HeIsMehrab\PhpRabbitMq\Core\Producer;

$configuration = require_once '/path/to/the/config-file';

$producer = new Producer($configuration);

try {
    for ($i = 1; $i  true,
            'time' => time(),
            'number' => $i
        ]);

        // Set a json encoded array of data via setMessage() method.
        $producer->setMessage($message);

        // According to default configuration file,
        // a message will send to a exchange with name `notifications`
        // with 'high' routing key.
        $producer->sendToQueue('high', 'notifications');
    }

    $producer->closeConnections();
} catch (Exception $e) {
    echo $e->getMessage();
}
```

#### Consumer:

[](#consumer)

```
use HeIsMehrab\PhpRabbitMq\Core\Consumer;

$configuration = require_once '/path/to/the/config-file';

$consumer = new Consumer($configuration);

$callBack = function ($message) {
    // The payload of the message that producer sent to Rabbitmq.
    $body = json_decode($message->body);

    var_dump($body);
    // some logics...

    $message->ack($message->delivery_info['delivery_tag']);
};

try {
    $consumer->listen('Q1', $callBack);
} catch (Exception $e) {
    echo $e->getMessage();
}
```

To be sure that Producer service closes the connections to Rabbitmq after sending messages/tasks, you can call the `closeConnections()` method, this method is available in both Producer and Consumer instances; note the Consumer call this method by its own, so you don't need to do that in manual for Consumer services.

```
$producer->closeConnections();
```

you can also take a look at [here](./example) directory of package to see more example oriented samples.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

1772d ago

Major Versions

0.9.0 → 1.0.02021-07-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/7243a943df059fad0e793cee55648ddc2685b6badd8564d8507a5e1879010591?d=identicon)[heismehrab](/maintainers/heismehrab)

---

Top Contributors

[![heismehrab](https://avatars.githubusercontent.com/u/40082310?v=4)](https://github.com/heismehrab "heismehrab (46 commits)")

### Embed Badge

![Health badge](/badges/heismehrab-php-rabbitmq-x/health.svg)

```
[![Health](https://phpackages.com/badges/heismehrab-php-rabbitmq-x/health.svg)](https://phpackages.com/packages/heismehrab-php-rabbitmq-x)
```

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[vladimir-yuldashev/laravel-queue-rabbitmq

RabbitMQ driver for Laravel Queue. Supports Laravel Horizon.

2.1k9.8M30](/packages/vladimir-yuldashev-laravel-queue-rabbitmq)[php-amqplib/rabbitmq-bundle

Integrates php-amqplib with Symfony &amp; RabbitMq. Formerly emag-tech-labs/rabbitmq-bundle, oldsound/rabbitmq-bundle.

1.3k20.1M65](/packages/php-amqplib-rabbitmq-bundle)[bschmitt/laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages

2752.3M7](/packages/bschmitt-laravel-amqp)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[enqueue/amqp-lib

Message Queue Amqp Transport

1078.5M61](/packages/enqueue-amqp-lib)

PHPackages © 2026

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