PHPackages                             vrnvgasu/php-rabbit-handler - 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. vrnvgasu/php-rabbit-handler

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

vrnvgasu/php-rabbit-handler
===========================

Handle queues

2.0.0(4y ago)27.6k↓64.3%[1 PRs](https://github.com/vrnvgasu/php-rabbit-handler/pulls)MITPHPPHP &gt;=8.1.0

Since Feb 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/vrnvgasu/php-rabbit-handler)[ Packagist](https://packagist.org/packages/vrnvgasu/php-rabbit-handler)[ RSS](/packages/vrnvgasu-php-rabbit-handler/feed)WikiDiscussions master Synced 2d ago

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

php-rabbit-handler
==================

[](#php-rabbit-handler)

composer require vrnvgasu/php-rabbit-handler

Look examples in `./Examples`.

Connection
----------

[](#connection)

Create new connection.

```
$connection = new Connection('localhost', 5672, 'guest', 'guest');
```

Queue
-----

[](#queue)

Create new queue.

```
$queue = new Queue('hello', false, false, false, false);
```

Pass '' as the first variable if you need a unique queue from rabbit.

Exchange
--------

[](#exchange)

Create new exchange.

```
$exchange = new Exchange('direct_logs', 'direct', false, false, false);
```

Bind queue and exchange
-----------------------

[](#bind-queue-and-exchange)

Create new binding.

```
$binding = new Binding();
```

You can create pass routing key in your binding.

```
$binding = new Binding('key');
```

Then you must to create helper and pass him $connection, $queue, $exchange and $binding.

```
$helper = new AMQPHelper($connection, $queue, $exchange, $binding);
```

Consuming
---------

[](#consuming)

Create new consume.

```
$consume = new Consume('', false, false,false, false);
```

You can pass callback function in Consume constructor to handle message from rabbit

```
$consume = new Consume('', false, false, false, false, function($msg) {
    print_r('Message: ' . $msg->body);
});
```

Or you can extend your consumer class from Consumer and declare `callback` method.

```
class TestConsumer extends Consumer
{
    /**
     * @param AMQPMessage $msg
     */
    public function callback(AMQPMessage $msg): void
    {
        print_r(' [x] Received ' . $msg->body . "\n");

        if (!$this->consume->getNoAck()) {
            $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
        }
    }
}
```

Then you must to create consumer and pass him $helper and $consume.

```
$consumer = new Consumer($helper, $publication);
```

Then call method `execute`.

```
$consumer->execute();
```

If you want to interrupt the execution of the handler after a while, then use:

```
$seconds = 60;
$consumer->execute(true, null, false, $seconds);
```

This will interrupt execution after the specified time after processing the last message.

Producing
---------

[](#producing)

Create new publication.

```
$publication = new Publication([], 'hello');
```

Then you must to create producer and pass him $helper and $publication.

```
$producer = new Producer($helper, $consume);
```

You need payload for your producer. Producer can get payload from objects which implements JobInterface.

You can pass your job object to Producer object

```
$producer->execute(TestJob::dispatch($param));
```

Or you can pass producer to the method `execute`.

```
TestJob::dispatch($param)->execute($producer);
```

Job
---

[](#job)

Prepare payload for producer.

#### Dispatch

[](#dispatch)

At the first you need to transfer data for preparation to `dispatch`.

```
use ATC\Jobs\TestJob;

TestJob::dispatch($param1, $param2, $param3);
```

#### Class declaration

[](#class-declaration)

Your TestJob must extends from `Job`

```
class TestJob extends BaseJob
{
    //
}
```

#### Handling

[](#handling)

In TestJob you must to declare method `handle` with params which you pass in `dispatch`. `handle` will execute in `dispatch`.

```
    protected function handle($param1, $param2, $param3)
    {
        // Parameters will be passed to this class automatically
        // You can do something with them and get some $data

        // In the same method, you need to transfer the payload to the method `payload` for `producer`
        $this->setPayload($data);
    }
```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity73

Established project with proven stability

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

Recently: every ~164 days

Total

11

Last Release

1549d ago

Major Versions

1.1.4 → 7.2.x-dev2020-06-19

2.0.0 → 8.1.x-dev2022-03-22

PHP version history (3 changes)1.0.0PHP &gt;=7.2.0

2.0.0PHP &gt;=8.1.0

8.0.x-devPHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32741644?v=4)[Dmitrii](/maintainers/vrnvgasu)[@vrnvgasu](https://github.com/vrnvgasu)

---

Top Contributors

[![vrnvgasu](https://avatars.githubusercontent.com/u/32741644?v=4)](https://github.com/vrnvgasu "vrnvgasu (8 commits)")

---

Tags

messagequeuerabbitmq

###  Code Quality

TestsPHPUnit

Static AnalysisRector

### Embed Badge

![Health badge](/badges/vrnvgasu-php-rabbit-handler/health.svg)

```
[![Health](https://phpackages.com/badges/vrnvgasu-php-rabbit-handler/health.svg)](https://phpackages.com/packages/vrnvgasu-php-rabbit-handler)
```

###  Alternatives

[php-amqplib/rabbitmq-bundle

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

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

AMQP wrapper for Laravel and Lumen to publish and consume messages

2822.5M7](/packages/bschmitt-laravel-amqp)[convenia/pigeon

3334.8k](/packages/convenia-pigeon)[kdyby/rabbitmq

Integrates php-amqplib with RabbitMq and Nette Framework

30721.3k4](/packages/kdyby-rabbitmq)

PHPackages © 2026

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