PHPackages                             innmind/amqp - 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. innmind/amqp

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

innmind/amqp
============

AMQP client

7.0.0(2mo ago)14.4k↑1400%1[2 issues](https://github.com/Innmind/AMQP/issues)MITPHPPHP ~8.4CI passing

Since Sep 12Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Innmind/AMQP)[ Packagist](https://packagist.org/packages/innmind/amqp)[ Docs](http://github.com/Innmind/AMQP)[ RSS](/packages/innmind-amqp/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (31)Used By (0)

AMQP
====

[](#amqp)

[![CI](https://github.com/Innmind/AMQP/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Innmind/AMQP/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/d2c241475cd16359def4531f8a7be6073fd1084d4ef9b4a2f3894be53f853ca6/68747470733a2f2f636f6465636f762e696f2f67682f496e6e6d696e642f414d51502f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/Innmind/AMQP)[![Type Coverage](https://camo.githubusercontent.com/0289edaaef184dff4921f76d0576c0863aad4500fe81a1ed78b9d64777bf0fae/68747470733a2f2f73686570686572642e6465762f6769746875622f496e6e6d696e642f414d51502f636f7665726167652e737667)](https://shepherd.dev/github/Innmind/AMQP)

This is an AMQP client implementing the version `0.9` of the protocol.

The goal of this implementation is to provide a PHP land implementation (for ease of use and readability) with a clear separation between the AMQP Model, transport layer and user API.

Note

This implementation couldn't have been done without [`php-amqplib`](https://packagist.org/packages/php-amqplib/php-amqplib) that helped a lot to figure out the details of the transport layer.

Important

If you are using RabbitMQ be aware that it doesn't implemented the specification completely, `Qos` and `Recover` methods are not implemented. And if you find yourself using [`Value`](src/Transport/Frame/Value.php) implementations note that `ShortString`, `SignedLongLongInteger` and `SignedShortInteger` generate server errors on some methods (like using them as message headers).

[Documentation](docs)

Important

You must use [`vimeo/psalm`](https://packagist.org/packages/vimeo/psalm) to make sure you use this library correctly.

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

[](#installation)

```
composer require innmind/amqp
```

Usage
-----

[](#usage)

```
use Innmind\AMQP\{
    Factory,
    Command\DeclareExchange,
    Command\DeclareQueue,
    Command\Bind,
    Command\Publish,
    Model\Basic\Message,
    Model\Exchange\Type,
};
use Innmind\IO\Sockets\Internet\Transport;
use Innmind\Time\Period;
use Innmind\OperatingSystem\Factory as OSFactory;
use Innmind\Url\Url;
use Innmind\Immutable\Str;

$os = OSFactory::build();
$client = Factory::of($os)
    ->make(
        Transport::tcp(),
        Url::of('amqp://guest:guest@localhost:5672/'),
        Period::second(1), // timeout
    )
    ->with(DeclareExchange::of('crawler', Type::direct))
    ->with(DeclareQueue::of('parser'))
    ->with(Bind::of('crawler', 'parser'))
    ->with(Publish::one(Message::of(Str::of('https://github.com')))->to('crawler'))
    ->run(null)
    ->unwrap();
```

The above example will declare an exchange named `crawler` and queue `parser` that will receive messages from our exchange. Finally it will publish a message with the payload `http://github.com/` to `crawler` (and the server will route it to `parser`).

And to consume the messages you have 2 approaches:

```
use Innminq\AMQP\{
    Command\Get,
    Command\Consume,
    Consumer\Continuation,
    Model\Basic\Message,
};

$state = $client
    ->with(Get::of('parser')->handle(static function($state, Message $message, Continuation $continuation) {
        $state = $message->body()->toString();

        return $continuation->ack($state);
    }))
    ->run(null) // unwrap();
echo $state; // will print "http://github.com/"
// or
$client
    ->with(Consume::of('crawler')->handle(static function($state, Message $message, Continuation $continuation) {
        doStuff($message);

        return $continuation->reject($state); // to reject the message
        return $continuation->requeue($state); // put the message back in the queue so it can be redelivered
        return $continuation->cancel($state); // instruct to stop receiving messages (current will be acknowledged first)
    }))
    ->run(null)
    ->unwrap(); // in this case only reachable when you cancel the consumer
```

`reject()` and `requeue()` can also be used in the `get` callback.

Feel free to look at the `Command` namespace to explore all capabilities.

Benchmarks
----------

[](#benchmarks)

`make benchmark` run on a MacBookPro18,2 (M1 Max, 32Gb RAM) with a RabbitMQ running in a container (via docker for mac) produces this result:

```
make benchmark
Publishing 4000 msgs with 1KB of content:
php benchmark/producer.php 4000
0.48978996276855
Consuming 4000:
php benchmark/consumer.php
Pid: 701, Count: 4000, Time: 2.3580

```

By comparison, the `php-amqplib` produces this result:

```
Publishing 4000 msgs with 1KB of content:
php benchmark/producer.php 4000
0.15483689308167
Consuming 4000:
php benchmark/consumer.php
Pid: 46862, Count: 4000, Time: 0.2366

```

So it appears *pure* functions come at a cost!

Note

both benchmarks use manual acknowledgement of messages

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance71

Regular maintenance activity

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

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

Recently: every ~220 days

Total

29

Last Release

76d ago

Major Versions

2.1.0 → 3.0.02020-03-07

3.2.0 → 4.0.02022-12-11

4.3.0 → 5.0.02024-03-10

5.1.0 → 6.0.02025-08-08

6.0.0 → 7.0.02026-02-22

PHP version history (7 changes)1.0.0PHP ~7.1

1.5.0PHP ~7.2

3.0.0PHP ~7.4

3.2.0PHP ~7.4|~8.0

4.0.0PHP ~8.1

4.3.0PHP ~8.2

7.0.0PHP ~8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (506 commits)")

---

Tags

amqpamqp-clientamqp0-9-1AMQP

### Embed Badge

![Health badge](/badges/innmind-amqp/health.svg)

```
[![Health](https://phpackages.com/badges/innmind-amqp/health.svg)](https://phpackages.com/packages/innmind-amqp)
```

###  Alternatives

[php-amqplib/rabbitmq-bundle

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

1.3k20.1M64](/packages/php-amqplib-rabbitmq-bundle)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[bunny/bunny

Performant pure-PHP AMQP (RabbitMQ) non-blocking ReactPHP library

7426.5M37](/packages/bunny-bunny)[enqueue/enqueue-bundle

Message Queue Bundle

27615.6M38](/packages/enqueue-enqueue-bundle)[swarrot/swarrot

A simple lib to consume RabbitMQ queues

3654.4M8](/packages/swarrot-swarrot)[enqueue/amqp-tools

Message Queue Amqp Tools

14721.1M12](/packages/enqueue-amqp-tools)

PHPackages © 2026

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