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

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

graze/queue
===========

:postbox: Flexible abstraction for working with queues in PHP.

v0.7.0(8y ago)4946.7k↓33.3%10[6 issues](https://github.com/graze/queue/issues)MITPHPPHP ^5.5|^7

Since Jun 29Pushed 8y ago24 watchersCompare

[ Source](https://github.com/graze/queue)[ Packagist](https://packagist.org/packages/graze/queue)[ RSS](/packages/graze-queue/feed)WikiDiscussions master Synced 3w ago

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

Queue
=====

[](#queue)

[![](https://camo.githubusercontent.com/38a85243f76e4d883b50e189fa9fe165dc3908d3dae7a3e7043e51ee98304396/687474703a2f2f692e67697068792e636f6d2f3130306d684554714b594a4e66322e676966)](https://camo.githubusercontent.com/38a85243f76e4d883b50e189fa9fe165dc3908d3dae7a3e7043e51ee98304396/687474703a2f2f692e67697068792e636f6d2f3130306d684554714b594a4e66322e676966)

[![PHP ~5.5](https://camo.githubusercontent.com/3dc78fae0ecf7aa1a262af003397c89ef507fc04752b7c669fc195f07e6ffb5d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344352e352d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://secure.php.net)[![Latest Version](https://camo.githubusercontent.com/cd07ba6e4cdaf46990707a63bc68335f4e19e140121192559715495351862c4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6772617a652f71756575652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graze/queue)[![MIT Licensed](https://camo.githubusercontent.com/963eca1dfe7c846214f3cc23031804c49fe492203dd78d884dd0ec78762d5ed7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6772617a652f71756575652e7376673f7374796c653d666c61742d737175617265)](https://github.com/graze/queue/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/859cb8f2bd853c6f79d728fd50816bce821ec2bdfa295140237ca4f2fdfa245d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6772617a652f71756575652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/graze/queue)[![Coverage Status](https://camo.githubusercontent.com/180ca352d5552f2022b4e10303d7c9026011eabaa1bf9aae6ae41457fb7e9268/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6772617a652f71756575652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/graze/queue/code-structure)[![Quality Score](https://camo.githubusercontent.com/58619bfc0c2f1de39dd191db23fb3222a1bfb583be3341a1feeb47ccba83490d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6772617a652f71756575652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/graze/queue)[![Total Downloads](https://camo.githubusercontent.com/46a800e2c35cb42b3f7c62721dae1bef4db61360e5944451b5ca48b8c925bfb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6772617a652f71756575652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graze/queue)

This library provides a flexible abstraction layer for working with queues.

It can be installed in whichever way you prefer, but we recommend [Composer](https://packagist.org/packages/graze/queue).

`~$ composer require graze/queue`

Documentation
-------------

[](#documentation)

Queue operations center around lists of Message objects. Whether you're sending one or multiple Messages, it's always an array. Workers work only on one Message object at a time, whether a list of one or multiple is received from the queue.

```
use Aws\Sqs\SqsClient;
use Graze\Queue\Adapter\SqsAdapter;
use Graze\Queue\Client;
use Graze\Queue\Message\MessageInterface;

$client = new Client(new SqsAdapter(new SqsClient([
    'region'  => 'us-east-1',
    'version' => '2012-11-05',
    'credentials' => [
        'key'    => 'ive_got_the_key',
        'secret' => 'ive_got_the_secret'
    ],
]), 'queue_name'));

// Producer
$client->send([
    $client->create('foo'),
]);

// Consumer
$client->receive(function (MessageInterface $msg) {
    var_dump($msg->getBody());
    var_dump($msg->getMetadata()->getAll());
});
```

### Adapters

[](#adapters)

The Adapter object is used to fulfill the low level requests to the queue provider.

Currently supported queue providers are:

- [Array](src/Adapter/ArrayAdapter.php)
- [AWS SQS](src/Adapter/SqsAdapter.php) (with the [AWS SDK](http://aws.amazon.com/sdk-for-php/))

### Handlers

[](#handlers)

The Handler object is used to execute worker callables with a list of received messages and handle Acknowledgement.

The current handlers are:

- [Batch Acknowledgement](src/Handler/BatchAcknowledgementHandler.php) to acknowledge batches
- [Eager Acknowledgement](src/Handler/EagerAcknowledgementHandler.php) to acknowledge immediately after work
- [Null Acknowledgement](src/Handler/NullAcknowledgementHandler.php) for development

```
use Graze\Queue\Client;
use Graze\Queue\Adapter\ArrayAdapter;
use Graze\Queue\Handler\BatchAcknowledgementHandler;
use Graze\Queue\Message\MessageInterface;

// Create client with the Batch Acknowledgement Handler.
$client = new Client(new ArrayAdapter(), [
    'handler' => new BatchAcknowledgementHandler(),
]);

// Receive a maximum of 10 messages.
$client->receive(function (MessageInterface $message) {
    // Do some work.
}, 10);
```

### Polling

[](#polling)

Polling a queue is supported by passing `null` as the limit argument to the `receive` method. The second argument given to your worker is a `Closure` you should use to stop polling when you're finished working. Make sure you use a handler that acknowledges work effectively too!

Note that the individual Adapter objects may decide to stop polling at any time. A likely scenario where it may stop would be if the queue is of finite length and all possible messages have been received.

```
use Graze\Queue\Client;
use Graze\Queue\Adapter\ArrayAdapter;
use Graze\Queue\Handler\BatchAcknowledgementHandler;
use Graze\Queue\Message\MessageInterface;

// Create client with the Batch Acknowledgement Handler.
$client = new Client(new ArrayAdapter(), [
    'handler' => new BatchAcknowledgeHandler(100), // Acknowledge after 100 messages.
]);

// Poll until `$done()` is called.
$client->receive(function (MessageInterface $message, Closure $done) {
    // Do some work.

    // You should always define a break condition (i.e. timeout, expired session, etc).
    if ($breakCondition) $done();
}, null);
```

License
-------

[](#license)

The content of this library is released under the **MIT License** by **Nature Delivered Ltd.**

You can find a copy of this license in [`LICENSE`](https://github.com/graze/queue/blob/master/LICENSE) or at .

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.7% 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 ~118 days

Recently: every ~105 days

Total

10

Last Release

2955d ago

Major Versions

v0.3.0 → 1.0.x-dev2016-06-24

PHP version history (3 changes)v0.1.0PHP &gt;=5.5

1.0.x-devPHP &gt;=5.6

v0.7.0PHP ^5.5|^7

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ea4a1e649e912ca72822e30e7652e4b09fc027b67514bcd0209c13bfe9667db?d=identicon)[sjparkinson](/maintainers/sjparkinson)

![](https://avatars.githubusercontent.com/u/637788?v=4)[graze.com](/maintainers/graze)[@graze](https://github.com/graze)

---

Top Contributors

[![adlawson](https://avatars.githubusercontent.com/u/200351?v=4)](https://github.com/adlawson "adlawson (39 commits)")[![sjparkinson](https://avatars.githubusercontent.com/u/51677?v=4)](https://github.com/sjparkinson "sjparkinson (21 commits)")[![joemeehan](https://avatars.githubusercontent.com/u/2518301?v=4)](https://github.com/joemeehan "joemeehan (5 commits)")[![wpillar](https://avatars.githubusercontent.com/u/188514?v=4)](https://github.com/wpillar "wpillar (3 commits)")[![biggianteye](https://avatars.githubusercontent.com/u/1482649?v=4)](https://github.com/biggianteye "biggianteye (1 commits)")[![jakewright](https://avatars.githubusercontent.com/u/5333300?v=4)](https://github.com/jakewright "jakewright (1 commits)")

---

Tags

phpqueuesqs

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.5M29](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6045.5M507](/packages/illuminate-bus)[uecode/qpush-bundle

Asynchronous processing for Symfony using Push Queues

1672.5M2](/packages/uecode-qpush-bundle)[jayazhao/think-queue-rabbitmq

为 ThinkPHP5.1 队列增加 RabbitMQ 驱动

141.5k](/packages/jayazhao-think-queue-rabbitmq)

PHPackages © 2026

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