PHPackages                             warren/warren - 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. warren/warren

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

warren/warren
=============

A simple, object-oriented library for creating RabbitMQ service workers.

1.2.2(8y ago)18GPL-3.0-or-laterPHPPHP &gt;=7.1.0

Since Mar 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/NGTOne/php-warren)[ Packagist](https://packagist.org/packages/warren/warren)[ Docs](https://github.com/NGTOne/warren)[ RSS](/packages/warren-warren/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (8)Versions (8)Used By (0)

Warren
======

[](#warren)

Warren is a lightweight PHP library that enables quick and easy creation of both synchronous and asynchronous RabbitMQ message consumers (the "sub" part of "pub/sub").

Features
--------

[](#features)

Warren is designed with two primary goals in mind:

1. Easy, testable, object-oriented creation of service workers that are capable of undertaking multiple *different* actions, both [request-only (asynchronous)](https://www.rabbitmq.com/tutorials/tutorial-two-php.html)and [request-response (synchronous)](https://www.rabbitmq.com/tutorials/tutorial-six-php.html).
2. Easy use of PSR7 middleware using the

```
function (
    RequestInterface $req,
    ResponseInterface $res,
    callable $next = null
) : ResponseInterface
```

idiom, with different middleware stacks for synchronous and asynchronous calls.

To this end, it provides an abstraction layer over the queue implementation, which converts the queue-specific message into a PSR7 object. Once the message has been successfully processed, it then goes the other way - converting the PSR7 response object back into the queue service's own internal representation.

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

[](#installation)

Installation is simple - just use [Composer](https://getcomposer.org/):

```
composer require warren/warren

```

Dependencies
------------

[](#dependencies)

Warren requires PHP 7.1 or higher. In addition, you will need to install at least one of the following libraries in order to use the corresponding queue bindings:

- [php-amqplib](https://github.com/php-amqplib/php-amqplib)

Getting Started with Warren
---------------------------

[](#getting-started-with-warren)

To create a Warren-based service worker, you need to implement at least one of `Warren\SynchronousAction` or `Warren\AsynchronousAction`. Then, just plug it (or them) into Warren using the fluent interface:

```
// Using the PhpAmqpLib connection adapter - others will be available soon
$rabbitConn = new AMQPStreamConnection('server', 5672, 'user', 'pass');
$channel = $rabbitConn->channel();
$channel->queue_declare('incoming_msg_queue');

$conn = new Warren\Connection\PhpAmqpLibConnection(
    $channel,
    'incoming_msg_queue'
);

$warren = new Warren\RabbitConsumer($conn);

$warren->addAsynchronousAction(new MyAwesomeAction, 'my_awesome_action')
    ->addSynchronousAction(new MySynchronousAction, 'my_sync_action')
    ->listen();
```

Each call corresponds to a separate action, not unlike an endpoint for an HTTP API. The message header to use to determine which action to take can be set with:

```
$warren->setActionHeader('my_header');
```

You can add PSR7 middleware to a Warren worker like so:

```
$warren
    ->addAsynchronousAction(new MyAwesomeAction, 'my_awesome_action')
    ->addAsynchronousMiddleware(function ($req, $res, $next) {
        return $next(
            $req,
            $res->withHeader('this', 'is so cool!')
        );
    })
    ->listen();
```

Synchronous and asynchronous actions have separate middleware stacks. Note that any response values for asynchronous actions *will* be ignored.

### Error Handling

[](#error-handling)

In the event that an exception or error propagates its way to the top of the call stack, Warren's got you covered - just drop any implementation of `Warren\ErrorHandler` into either of the following two methods:

```
$warren
    ->setErrorHandler($myAwesomeHandler)
    ->setReplyErrorHandler($myAwesomeReplyHandler);
```

The error handler provided to `setErrorHandler` will be invoked if issues are encountered while processing the message. The handler provided to `setReplyErrorHandler` will be used if a problem is encountered while sending a reply message or acknowledging that the message has been processed.

### Handling Signals

[](#handling-signals)

One of the most common requirements for RabbitMQ service workers is to allow tasks to run to completion, regardless of whether or not the service has been instructed to shut down. For this use case, Warren provides the abstract class `Warren\Signal\SignalHandler` - simply implement its `handleSignals()` method, and drop it into Warren like so:

```
$warren
    ->setSignalHandler($myAwesomeHandler);
```

By default, Warren will handle `SIGTERM`, `SIGINT`, and `SIGHUP`, and exit after completion of the current task.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Total

6

Last Release

2956d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5864ca5011a8f71d9c7bd18422182ab4f2114af73f4ea0ec1a3702a9924ef58a?d=identicon)[NGTOne](/maintainers/NGTOne)

---

Top Contributors

[![NGTOne](https://avatars.githubusercontent.com/u/6420410?v=4)](https://github.com/NGTOne "NGTOne (185 commits)")

---

Tags

messagequeuerabbitmq

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[php-amqplib/php-amqplib

Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.

4.6k125.3M879](/packages/php-amqplib-php-amqplib)[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)[bunny/bunny

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

7426.5M37](/packages/bunny-bunny)[pdezwart/php-amqp

PHP AMQP Binding Library

585242.0k2](/packages/pdezwart-php-amqp)[php-amqp/php-amqp

PHP AMQP Binding Library

5855.1k](/packages/php-amqp-php-amqp)[kdyby/rabbitmq

Integrates php-amqplib with RabbitMq and Nette Framework

30693.1k4](/packages/kdyby-rabbitmq)

PHPackages © 2026

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