PHPackages                             alveos/swarrot - 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. alveos/swarrot

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

alveos/swarrot
==============

A simple lib to consume RabbitMQ queues

v4.20.0(5mo ago)3652.0k↓50%55[2 PRs](https://github.com/swarrot/swarrot/pulls)MITPHPPHP ^8.2CI passing

Since Mar 25Pushed 3mo ago14 watchersCompare

[ Source](https://github.com/swarrot/swarrot)[ Packagist](https://packagist.org/packages/alveos/swarrot)[ RSS](/packages/alveos-swarrot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (62)Used By (0)

Swarrot
=======

[](#swarrot)

[![Build Status](https://camo.githubusercontent.com/7e14b7e35dfe8d466900126040e9e31de285c2a67f72fc223e3a5662ec48fdfd/68747470733a2f2f7472617669732d63692e6f72672f73776172726f742f73776172726f742e706e67)](https://travis-ci.org/swarrot/swarrot)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/92c656fee30d507129bba8585831531c764ab7c3421d58350ffeba1fabf66971/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73776172726f742f73776172726f742f6261646765732f7175616c6974792d73636f72652e706e673f733d32633735396236323234633736326663333061393032643636316235353132353936303630373533)](https://scrutinizer-ci.com/g/swarrot/swarrot/)[![Latest Stable Version](https://camo.githubusercontent.com/4d1b2c119f77d65cbc714b51fb25b6d4ebbc258b1a51dff9db5330070157335e/68747470733a2f2f706f7365722e707567782e6f72672f73776172726f742f73776172726f742f762f737461626c652e737667)](https://packagist.org/packages/swarrot/swarrot)[![Latest Unstable Version](https://camo.githubusercontent.com/723aacf35f9c89c1840d90658cb2cbf9e361d29a2bb36a1246874ecb1655c305/68747470733a2f2f706f7365722e707567782e6f72672f73776172726f742f73776172726f742f762f756e737461626c652e737667)](https://packagist.org/packages/swarrot/swarrot)

Swarrot is a PHP library to consume messages from any broker.

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

[](#installation)

The recommended way to install Swarrot is through [Composer](http://getcomposer.org/). Require the `swarrot/swarrot` package:

```
$ composer require swarrot/swarrot

```

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

First, you need to create a message provider to retrieve messages from your broker. For example, with a `PeclPackageMessageProvider` (retrieves messages from an AMQP broker with the [pecl amqp package](http://pecl.php.net/package/amqp):

```
use Swarrot\Broker\MessageProvider\PeclPackageMessageProvider;

// Create connection
$connection = new \AMQPConnection();
$connection->connect();
$channel = new \AMQPChannel($connection);
// Get the queue to consume
$queue = new \AMQPQueue($channel);
$queue->setName('global');

$messageProvider = new PeclPackageMessageProvider($queue);
```

Once it's done you need to create a `Processor` to process messages retrieved from the broker. This processor must implement `Swarrot\Processor\ProcessorInterface`. For example:

```
use Swarrot\Processor\ProcessorInterface;
use Swarrot\Broker\Message;

class Processor implements ProcessorInterface
{
    public function process(Message $message, array $options): bool
    {
        echo sprintf("Consume message #%d\n", $message->getId());

        return true; // Continue processing other messages
    }
}
```

You now have a `Swarrot\Broker\MessageProviderInterface` to retrieve messages and a Processor to process them. So, ask the `Swarrot\Consumer` to do its job :

```
use Swarrot\Consumer;

$consumer = new Consumer($messageProvider, $processor);
$consumer->consume();
```

### Using a stack

[](#using-a-stack)

Heavily inspired by [stackphp/builder](https://github.com/stackphp/builder) you can use `Swarrot\Processor\Stack\Builder` to stack your processors. Using the [built in processors](#official-processors) or by [creating your own](#create-your-own-processor), you can extend the behavior of your base processor. In this example, your processor is decorated by 2 other processors. The [ExceptionCatcherProcessor](src/Swarrot/Processor/ExceptionCatcher/ExceptionCatcherProcessor.php)which decorates your own with a try/catch block and the [MaxMessagesProcessor](src/Swarrot/Processor/MaxMessages/MaxMessagesProcessor.php)which stops your worker when some messages have been consumed.

```
use Swarrot\Processor\ProcessorInterface;
use Swarrot\Broker\Message;

class Processor implements ProcessorInterface
{
    public function process(Message $message, array $options): bool
    {
        echo sprintf("Consume message #%d\n", $message->getId());

        return true; // Continue processing other messages
    }
}

$stack = (new \Swarrot\Processor\Stack\Builder())
    ->push('Swarrot\Processor\MaxMessages\MaxMessagesProcessor', new Logger())
    ->push('Swarrot\Processor\ExceptionCatcher\ExceptionCatcherProcessor')
    ->push('Swarrot\Processor\Ack\AckProcessor', $messageProvider)
;

$processor = $stack->resolve(new Processor());
```

Here is an illustration to show you what happens when this order is used:

[![this](https://github.com/user-attachments/assets/b1aa419d-f10a-44ef-895b-a995c3215aa6)](https://github.com/user-attachments/assets/b1aa419d-f10a-44ef-895b-a995c3215aa6)

Processors
----------

[](#processors)

### Official processors

[](#official-processors)

- [AckProcessor](src/Swarrot/Processor/Ack)
- [Doctrine related processors](src/Swarrot/Processor/Doctrine) (thanks to [Adrien Brault](https://github.com/adrienbrault))
- [ExceptionCatcherProcessor](src/Swarrot/Processor/ExceptionCatcher)
- [InsomniacProcessor](src/Swarrot/Processor/Insomniac) (thanks to [Adrien Brault](https://github.com/adrienbrault))
- [InstantRetryProcessor](src/Swarrot/Processor/InstantRetry)
- [MaxExecutionTimeProcessor](src/Swarrot/Processor/MaxExecutionTime) (thanks to [Remy Lemeunier](https://github.com/remyLemeunier))
- [MaxMessagesProcessor](src/Swarrot/Processor/MaxMessages) (thanks to [Remy Lemeunier](https://github.com/remyLemeunier))
- [MemoryLimitProcessor](src/Swarrot/Processor/MemoryLimit) (thanks to [Christophe Coevoet](https://github.com/stof))
- [RetryProcessor](src/Swarrot/Processor/Retry)
- [ServicesResetterProcessor](src/Swarrot/Processor/ServicesResetter) (thanks to [Pierrick Vignand](https://github.com/pvgnd))
- [SignalHandlerProcessor](src/Swarrot/Processor/SignalHandler)
- [XDeathMaxCountProcessor](src/Swarrot/Processor/XDeath) (thanks to [Anthony Moutte](https://github.com/instabledesign))
- [XDeathMaxLifetimeProcessor](src/Swarrot/Processor/XDeath) (thanks to [Anthony Moutte](https://github.com/instabledesign))

### Create your own processor

[](#create-your-own-processor)

To create your own processor and be able to use it with the `StackProcessor`, you just need to implement `ProcessorInterface` and to take another `ProcessorInterface` as first argument in constructor.

Deprecated processors &amp; message providers / publishers
----------------------------------------------------------

[](#deprecated-processors--message-providers--publishers)

In order to reduce `swarrot/swarrot` dependencies &amp; ease the maintenance, some processors &amp; message providers / publishers have been deprecated in 3.x version. They will be deleted in 4.0.

If you use those deprecated classes you could create your own repository to keep them or we could create a dedicated repository under the swarrot organisation if you're willing to help to maintain them.

### Message providers / publishers

[](#message-providers--publishers)

- SQS Message provider (in 3.5.0)
- Stomp message providers (in 3.6.0)
- Stomp message publishers (in 3.7.0)
- Interop message publishers &amp; providers (in 3.7.0)

### Processors

[](#processors-1)

- SentryProcessor (in 3.5.0)
- RPC related processors (in 3.5.0)
- NewRelicProcessor (in 3.7.0)

Inspiration
-----------

[](#inspiration)

- [stackphp/builder](https://github.com/stackphp/builder)

License
-------

[](#license)

Swarrot is released under the MIT License. See the bundled LICENSE file for details.

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance76

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 53.5% 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 ~73 days

Recently: every ~203 days

Total

59

Last Release

157d ago

Major Versions

v1.6.2 → v2.0.02015-06-03

v2.4.0 → v3.0.02017-07-20

v3.7.0 → v4.0.02020-02-05

PHP version history (8 changes)v1.0.0PHP &gt;=5.3.3

v1.3.0PHP &gt;=5.4

v2.3.0PHP ^5.4 || ^7.0

v3.0.0PHP ^7.1

v3.5.0PHP ^7.2

v4.10PHP &gt;7.2.5 || ^8.0

v4.12.0PHP ^7.4 || ^8.0

v4.19.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/798295?v=4)[Jacques Moati](/maintainers/Jmoati)[@Jmoati](https://github.com/Jmoati)

---

Top Contributors

[![odolbeau](https://avatars.githubusercontent.com/u/680206?v=4)](https://github.com/odolbeau "odolbeau (221 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (75 commits)")[![Taluu](https://avatars.githubusercontent.com/u/239685?v=4)](https://github.com/Taluu "Taluu (12 commits)")[![metfan](https://avatars.githubusercontent.com/u/1121867?v=4)](https://github.com/metfan "metfan (12 commits)")[![borisbabic](https://avatars.githubusercontent.com/u/1743184?v=4)](https://github.com/borisbabic "borisbabic (10 commits)")[![greg0ire](https://avatars.githubusercontent.com/u/657779?v=4)](https://github.com/greg0ire "greg0ire (9 commits)")[![remyLemeunier](https://avatars.githubusercontent.com/u/1381360?v=4)](https://github.com/remyLemeunier "remyLemeunier (9 commits)")[![instabledesign](https://avatars.githubusercontent.com/u/1098878?v=4)](https://github.com/instabledesign "instabledesign (8 commits)")[![nicolasThal](https://avatars.githubusercontent.com/u/2675545?v=4)](https://github.com/nicolasThal "nicolasThal (7 commits)")[![AurelienPillevesse](https://avatars.githubusercontent.com/u/16165438?v=4)](https://github.com/AurelienPillevesse "AurelienPillevesse (5 commits)")[![lyrixx](https://avatars.githubusercontent.com/u/408368?v=4)](https://github.com/lyrixx "lyrixx (5 commits)")[![rflavien](https://avatars.githubusercontent.com/u/5444185?v=4)](https://github.com/rflavien "rflavien (4 commits)")[![adrienbrault](https://avatars.githubusercontent.com/u/611271?v=4)](https://github.com/adrienbrault "adrienbrault (3 commits)")[![lepiaf](https://avatars.githubusercontent.com/u/1940947?v=4)](https://github.com/lepiaf "lepiaf (3 commits)")[![MattKetmo](https://avatars.githubusercontent.com/u/334996?v=4)](https://github.com/MattKetmo "MattKetmo (3 commits)")[![yguedidi](https://avatars.githubusercontent.com/u/1480128?v=4)](https://github.com/yguedidi "yguedidi (3 commits)")[![astorije](https://avatars.githubusercontent.com/u/113730?v=4)](https://github.com/astorije "astorije (2 commits)")[![JLepeltier](https://avatars.githubusercontent.com/u/1286287?v=4)](https://github.com/JLepeltier "JLepeltier (2 commits)")[![olaurendeau](https://avatars.githubusercontent.com/u/1516110?v=4)](https://github.com/olaurendeau "olaurendeau (2 commits)")[![krichprollsch](https://avatars.githubusercontent.com/u/562696?v=4)](https://github.com/krichprollsch "krichprollsch (2 commits)")

---

Tags

hacktoberfestphpqueuequeueingrabbitrabbitmqswarrotqueueAMQPworkerswarrot

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[swarrot/swarrot

A simple lib to consume RabbitMQ queues

3654.4M8](/packages/swarrot-swarrot)[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)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[prolic/humus-amqp

PHP-AMQP library with RabbitMQ Extensions

76205.4k5](/packages/prolic-humus-amqp)

PHPackages © 2026

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