PHPackages                             dkhorev/laravel-ampq - 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. dkhorev/laravel-ampq

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

dkhorev/laravel-ampq
====================

Pub/Sub with RabbitMQ in Laravel.

1.0.7(4y ago)1100[2 PRs](https://github.com/dkhorev/laravel-ampq/pulls)MITPHPPHP &gt;=8.0||&gt;=7.4

Since Apr 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/dkhorev/laravel-ampq)[ Packagist](https://packagist.org/packages/dkhorev/laravel-ampq)[ RSS](/packages/dkhorev-laravel-ampq/feed)WikiDiscussions master Synced yesterday

READMEChangelog (8)Dependencies (2)Versions (11)Used By (0)

Laravel RabbitMQ helper
=======================

[](#laravel-rabbitmq-helper)

Pub/Sub with RabbitMQ in Laravel.

### Installation

[](#installation)

`composer require dkhorev/laravel-ampq`

### Publish configs

[](#publish-configs)

`php artisan vendor:publish --tag=laravel-ampq --force`

### Listeners

[](#listeners)

setup your listeners in `laravel-ampq.cfg`

```
'callbacks' => [
    'example_stack' => [
        'exchange' => [
            'topic' => ExampleListenerCallback::class,
        ],
    ],
],

```

this will listen for message on "exchange:topic" and pass any messages to `ExampleListenerCallback->__invoke()` method

every listener should implement `AmpqListenCallbackContract` (\_\_invoke() method)

```
use dkhorev\LaravelAmpq\Contracts\AmpqListenCallbackContract;
use PhpAmqpLib\Message\AMQPMessage;

class MyTopicCallback implements AmpqListenCallbackContract
{
    public function __invoke(AMQPMessage $msg): void
    {
        // TODO: Implement __invoke() method.
    }
}
```

it is recommended to only do basic validation of messages in a callback, and queue any heavy processing jobs (to redis or whatever)

### Listen command

[](#listen-command)

`php artisan ampq:listen {connection} {listenStack}`

`connection` - connection name from config's `servers` array

`listenStack` - stack of listening channels from config's `callbacks` array`

### Sending messages

[](#sending-messages)

To send a message with this package, you can use any connection from `laravel-ampq.cfg`

#### Using "local" connection (example)

[](#using-local-connection-example)

```
use dkhorev\LaravelAmpq\Clients\AmpqClient;
use dkhorev\LaravelAmpq\Contracts\SendToTopicServiceContract;

$config = config('laravel-ampq.servers.local');

$client =  new AmpqClient($config['host'], $config['user'], $config['password'], (int)$config['port']);
$sender = resolve(SendToTopicServiceContract::class);
$sender->postTo($client, 'some-exchange', 'some-topic', ['exapmple-data' => 'hello world!']);
```

#### Creating custom client connections

[](#creating-custom-client-connections)

add custom server to config

```
'servers' => [
    'custom' => [
    ...
    ],
],

```

extend `AmpqClient` from this package and create an interface, i.e. `AmpqClientCustomInterface`

```
use dkhorev\LaravelAmpq\Clients\AmpqClient;

class AmpqClientCustom extends AmpqClient implements AmpqClientCustomInterface
{}
```

in your app's `AppServiceProvider` bind new interface `AmpqClientCustomInterface` to resolve with custom server

```
$this->app->bind(
    AmpqClientCustomInterface::class,
    static function () {
        $config = config('laravel-ampq.servers.custom');

        return new AmpqClientCustom($config['host'], $config['user'], $config['password'], $config['port']);
    }
);
```

### Sending messages

[](#sending-messages-1)

```
use dkhorev\LaravelAmpq\Contracts\SendToTopicServiceContract;

$sender = resolve(SendToTopicServiceContract::class);
$client = resolve(AmpqClientCustomInterface::class);

$sender->postTo($client, 'some-exchange', 'some-topic', ['exapmple-data' => 'hello world!']);
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 70% 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 ~51 days

Recently: every ~67 days

Total

8

Last Release

1498d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21098285?v=4)[Dmitry Khorev](/maintainers/dkhorev)[@dkhorev](https://github.com/dkhorev)

---

Top Contributors

[![dkhorev](https://avatars.githubusercontent.com/u/21098285?v=4)](https://github.com/dkhorev "dkhorev (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

ampqlaravellaravel-ampqlaravel-rabbitmqrabbitmq

### Embed Badge

![Health badge](/badges/dkhorev-laravel-ampq/health.svg)

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

###  Alternatives

[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)[enqueue/amqp-lib

Message Queue Amqp Transport

1078.5M61](/packages/enqueue-amqp-lib)[jwage/phpamqplib-messenger

Symfony messenger transport for the php-amqplib/php-amqplib library.

84149.7k1](/packages/jwage-phpamqplib-messenger)[mikemadisonweb/yii2-rabbitmq

Wrapper based on php-amqplib to incorporate messaging in your Yii2 application via RabbitMQ. Inspired by RabbitMqBundle for Symfony 2, really awesome package.

74262.1k1](/packages/mikemadisonweb-yii2-rabbitmq)

PHPackages © 2026

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