PHPackages                             nelsonsar/microqueue - 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. nelsonsar/microqueue

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

nelsonsar/microqueue
====================

159932PHP

Since Feb 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/nelsonsar/microqueue)[ Packagist](https://packagist.org/packages/nelsonsar/microqueue)[ RSS](/packages/nelsonsar-microqueue/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

microqueue
==========

[](#microqueue)

A tiny (and extremely opinionated) framework to use [mqueue](http://linux.die.net/man/7/mq_overview) and stop to use tables as queues.

Why?
----

[](#why)

When companies need to make fast solutions for notification or communication with customer a lot of them use database tables as queues which are hard to maintain and use a lot of database resources. Besides all, it always involves nasty things (and you can see some of them [here](https://blog.engineyard.com/2011/5-subtle-ways-youre-using-mysql-as-a-queue-and-why-itll-bite-you/)) and side effects.

How it works?
-------------

[](#how-it-works)

It's really, really simple:

1. Declare a queue with a **string** name;
2. Create a consumer for that queue;
3. Create a producer for the same queue;
4. Publish messages!

`MicroQueue` does not have any configuration and use events to give you more flexibility! (Of course it was the only thing that I could think to avoid my consumer to know the producer... So, sorry).

The script below is an example of how simple it is:

```
// Consumer.php
$queue = MicroQueue\Queue::declareQueue('sms');

$eventDispatcher = new \Armadillo\EventDispatcher;

$consumer = new MicroQueue\Consumer($queue, $eventDispatcher);

$consumer->consume(function($message, $eventDispatcher) {
    // your code for consuming messages
}

// Producer.php
$queue = MicroQueue\Queue::declareQueue('sms');

$producer = new MicroQueue\Producer($queue);

$producer->publish('This is a test' . PHP_EOL);
```

This should be enough to start publishing messages. The *examples* folder has one example on how to use events to extend consumer functionality.

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

[](#installation)

This package is available on [Packagist](https://packagist.org/packages/nelsonsar/microqueue) and you can use [composer](https://getcomposer.org/) to install it.

MicroQueue is a replacement for other services?
-----------------------------------------------

[](#microqueue-is-a-replacement-for-other-services)

**NO**. Because of the following reasons:

- `MicroQueue` has a blocking nature (and most of the other services have not) and this is not nice for big jobs;
- `MicroQueue` is limited by session (consumer and producer need to exist in same session of Linux, for example) and by your OS (OS controls number of queues, number of messages and message size);
- `MicroQueue` tests will start soon (in a production environment) so I cannot ensure its reliability.

Tests
-----

[](#tests)

`Producer` and `Consumer` test will use `mqueue` installed in your machine. If you cannot run them for some hardware limitation, please use the [vagrant](https://www.vagrantup.com/) machine to do it. And sorry for have no idea on how I could have done unit tests.

Further work
------------

[](#further-work)

- Use another event lib like `evenement` (that is also tiny);
- Create a console app to help to create consumers as daemons;

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/34db61d9dadc52cb115c5c2539c6dc7b9856fcb3fa9f7619688a25665b7855b5?d=identicon)[nelsonsar](/maintainers/nelsonsar)

---

Top Contributors

[![nelsonsar](https://avatars.githubusercontent.com/u/905567?v=4)](https://github.com/nelsonsar "nelsonsar (16 commits)")[![batusa](https://avatars.githubusercontent.com/u/5388003?v=4)](https://github.com/batusa "batusa (1 commits)")

### Embed Badge

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

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[deliciousbrains/wp-background-processing

WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.

1.1k409.8k6](/packages/deliciousbrains-wp-background-processing)[react/async

Async utilities and fibers for ReactPHP

2228.8M171](/packages/react-async)[react/promise-stream

The missing link between Promise-land and Stream-land for ReactPHP

11512.9M45](/packages/react-promise-stream)[illuminate/bus

The Illuminate Bus package.

6043.8M409](/packages/illuminate-bus)

PHPackages © 2026

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