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

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

poirot/queue
============

Serve as an abstract layer between your application code and the implementation of the queue.

0129PHP

Since Jul 15Pushed 7y ago3 watchersCompare

[ Source](https://github.com/phPoirot/Queue)[ Packagist](https://packagist.org/packages/poirot/queue)[ RSS](/packages/poirot-queue/feed)WikiDiscussions devel Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Queue
=====

[](#queue)

Consumer

```
$client     = \Module\MongoDriver\Actions::Driver()->getClient('master');
$collection = $client->selectCollection('papioniha', 'queue.app');

$q = new MongoQueue($collection);

$message = (object)['ver'=>'0.1', 'to'=>'naderi.payam@gmail.com', 'template'=>'welcome'];
$qd      = $q->push('send-mails', new BasePayload($message) );

// message was queued on: 1500196427
// stdClass Object ( [ver] => 0.1 [to] => naderi.payam@gmail.com [template] => welcome )
print_r('message was queued on: '. $qd->getCreatedTimestamp() );
print_r( $qd->getPayload() );

$qID = $qd->getUID(); // 596b2e4bed473800180dfdb2
```

Producer

```
$client     = \Module\MongoDriver\Actions::Driver()->getClient('master');
$collection = $client->selectCollection('papioniha', 'queue.app');

$q = new MongoQueue($collection);
while ($QueuedMessage = $q->pop('send-mails')) {
    $payload = $QueuedMessage->getPayload();
    switch ($payload->ver) {
        case '0.1':
            print_r($payload);
            // $mail->sendTo($payload->to, $payload->tempate);
            break;
    }

    $q->release($QueuedMessage);
}
```

Aggregate Queue With Priority Weight
------------------------------------

[](#aggregate-queue-with-priority-weight)

```
$queue = new InMemoryQueue();

# Build Aggregate Queue
#
$qAggregate = new AggregateQueue([
    // Send Authorization SMS With Higher Priority
    'send-sms-auth'   => [ $queue, 0.9 ],
    // Normal Messages
    'send-sms-notify' => [ $queue, 0.2 ],
]);

# Add To Queue
#
for ($i =0; $i'0.1', 'to'=>'0935549'.$postfix, 'template'=>'auth', 'code' => $code];

    $qAggregate->push(new BasePayload($message), 'send-sms-auth');
}

for ($i =0; $i'0.1', 'to'=>'0935549'.$postfix, 'template'=>'welcome'];

    $qAggregate->push(new BasePayload($message), 'send-sms-notify');
}

# Pop From Queue send SMS
#
while ( $payload = $qAggregate->pop() ) {
    $size = $qAggregate->size('send-sms-auth');
    if (!isset($skip) && $size == 0 ) {
        $behind = $qAggregate->size('send-sms-notify');
        print_r(sprintf('Sending Auth SMS Done While Normal Queue Has (%s) in list.', $behind));
        echo '';

        $skip = true;
    }

    // release message
    $qAggregate->release($payload);
}
```

Worker
------

[](#worker)

```
$client     = \Module\MongoDriver\Actions::Driver()->getClient('master');
$collection = $client->selectCollection('papioniha', 'queue.app');

$queue = new MongoQueue($collection);

# Build Aggregate Queue
#
$qAggregate = new AggregateQueue([
    'threads_high' => [ $queue, 9 ],
    'threads'      => [ $queue, 2 ],
    'will_failed'  => [ $queue, 2 ],
]);

function will_failed($arg)
{
    static $failed = [];
    if (!isset($failed[$arg])) {
        echo date('H:i:s').' > '.$arg.' Will Failed; and retry again.'.'';
        $failed[$arg] = true;
        throw new \Exception();

    } else {
        echo date('H:i:s').' > '.$arg.' Recovering Failed.'.'';
    }

}

# Add To Queue
#
for ($i =1; $i'0.1', 'fun'=> 'print_r', 'args'=> [" ($i) From High"] ];
    $qAggregate->push(new BasePayload($message), 'threads_high');
}

# Add To Queue
#
for ($i =1; $i'0.1', 'fun'=> 'print_r', 'args'=> [" ($i) Normal"] ];
    $qAggregate->push(new BasePayload($message), 'threads');
}

# Add To Queue
#
for ($i =1; $i'0.1', 'fun'=> '\Module\OAuth2\Actions\User\will_failed', 'args' => [ random_int(1, 100) ] ];
    $qAggregate->push(new BasePayload($message), 'will_failed');
}

$worker = new Worker('my_worker', $qAggregate, [
    'built_in_queue' => $queue,
]);

$worker->go();
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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/1f784f9dfb58e36b6a876f3057e5664bb904af71d30bb2023583118138dffe9a?d=identicon)[Payam](/maintainers/Payam)

---

Top Contributors

[![E1101](https://avatars.githubusercontent.com/u/427575?v=4)](https://github.com/E1101 "E1101 (45 commits)")[![zimberkazmiz](https://avatars.githubusercontent.com/u/2890831?v=4)](https://github.com/zimberkazmiz "zimberkazmiz (3 commits)")

### Embed Badge

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

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

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

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)[amphp/serialization

Serialization tools for IPC and data storage in PHP.

13451.1M18](/packages/amphp-serialization)[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

2238.8M171](/packages/react-async)

PHPackages © 2026

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