PHPackages                             nilportugues/eventbus-queue - 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. nilportugues/eventbus-queue

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

nilportugues/eventbus-queue
===========================

Event Bus Queue library. Allows implementing asynchronous Event Bus.

1.1.3(9y ago)122.5k[2 issues](https://github.com/PHPMessageBus/event-bus-queue/issues)MITPHPPHP &gt;=7

Since Apr 17Pushed 9y agoCompare

[ Source](https://github.com/PHPMessageBus/event-bus-queue)[ Packagist](https://packagist.org/packages/nilportugues/eventbus-queue)[ Docs](http://nilportugues.com)[ RSS](/packages/nilportugues-eventbus-queue/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (9)Versions (6)Used By (0)

EventBus Queue
==============

[](#eventbus-queue)

[![Build Status](https://camo.githubusercontent.com/374545ceb0ccd88935d6bde0e29ce542e579c4955e50ac66c258ec198f047211/68747470733a2f2f7472617669732d63692e6f72672f5048504d6573736167654275732f6576656e746275732d71756575652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/PHPMessageBus/eventbus-queue) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/4acac083a77eca53c42a12296db438e45d5f7725a5fc3be4c487fc72846beacb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5048504d6573736167654275732f6576656e746275732d71756575652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/PHPMessageBus/eventbus-queue/?branch=master) [![SensioLabsInsight](https://camo.githubusercontent.com/cfb8ec5d24a75199c062c30ba7de1a46d7ce6ffc62a0354e4c6a554903dcbd8d/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33653466336531332d613863312d346631652d613561642d3432653739393931356466652f6d696e692e706e673f676f6c64)](https://insight.sensiolabs.com/projects/3e4f3e13-a8c1-4f1e-a5ad-42e799915dfe) [![Latest Stable Version](https://camo.githubusercontent.com/5a0ec36452ae378e4ec3357eff8c72b7ad65deccb807971f144fe1613646f50b/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f6576656e746275732d71756575652f762f737461626c653f)](https://packagist.org/packages/nilportugues/eventbus-queue) [![Total Downloads](https://camo.githubusercontent.com/23963a4fa98837397cbdc943001e673546c610ca673164935cec46d2e4b3cb1a/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f6576656e746275732d71756575652f646f776e6c6f6164733f)](https://packagist.org/packages/nilportugues/eventbus-queue) [![License](https://camo.githubusercontent.com/23791f72c88e0662751b599509dc8867c2e25c4ba9b193249b85fffcac8f247f/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f6576656e746275732d71756575652f6c6963656e73653f)](https://packagist.org/packages/nilportugues/eventbus-queue)[![Donate](https://camo.githubusercontent.com/7b6de155df30b37b25eb5fec52f9213680c3dbf067dfb7d7e2850ac4096c7d05/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e6174655f534d2e676966)](https://paypal.me/nilportugues)

- [Installation](#installation)
- [Usage](#usage)
    - [ProducerEventBus](#producereventbus)
    - [Consumer for the ProducerEventBus](#consumer-for-the-producereventbus)
    - [EventBusWorker](#eventbusworker)
- [Adapter Configurations](#adapter-configurations)
    - [PDOQueue](#pdoqueue)
    - [MongoDBQueue](#mongodbqueue)
    - [RedisQueue](#redisqueue)
    - [PredisQueue](#predisqueue)
    - [FileSystemQueue](#filesystemqueue)
    - [AmqpQueue](#amqpqueue)
    - [BeanstalkdQueue](#beanstalkdqueue)
- [Contribute](#contribute)
- [Support](#support)
- [Authors](#authors)
- [License](#license)

This package is an extension library for **[nilportugues/messagebus](http://github.com/PHPMessageBus/messagebus)**, adding queues to the EventBus implementation.

This package will provide you for the classes necessary to build:

- **The Producer**: code that sends the Event to a Queue by serializing the Event. This happens synchronously.
- **The Consumer**: code that reads in the background, therefore asynchronously, reads and unserializes the Event from the Queue and passes it to the EventBus to do the heavy lifting.

Why?
----

[](#why)

It's all about deciding which command logic can be delayed, or hidden away in order to make it faster. And this is what we want to do.

**You never remove a bottleneck, you just move it.** The downside is that we might have to assume a possible delay.

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

[](#installation)

In order to start using this project you require to install it using [Composer](https://getcomposer.org):

```
composer require nilportugues/eventbus-queue

```

Usage
-----

[](#usage)

This package will provide you with a new middleware: `ProducerEventBusMiddleware`.

This middleware requires a serializer and a storage that will depend on the Queue Adapter used. Supported adapters are:

- **PDOQueue**: queue built with a SQL database using Doctrine's DBAL.
- **MongoDBQueue**: queue built with MongoDB library.
- **RedisQueue**: queue using the Redis PHP extension.
- **PredisQueue**: queue using the Predis library.
- **FileSystemQueue**: queue built with using the local file system.
- **AmqpQueue**: use RabbitMQ or any queue implementing the Amqp protocol.
- **BeanstalkdQueue**: use Beanstalk as queue.

To set it up, register the `ProducerEventBusMiddleware` to the Event Bus. Because we'll need to define a second EventBus (consumer), we'll call this the `ProducerEventBus`.

#### ProducerEventBus

[](#producereventbus)

```
