PHPackages                             justblackbird/amphp-priority-emitter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. justblackbird/amphp-priority-emitter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

justblackbird/amphp-priority-emitter
====================================

In-memory implementation of async emitter with prioritized messages

0.4.0(5y ago)292MITPHPPHP ^7.4

Since Jul 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/JustBlackBird/amphp-priority-emitter)[ Packagist](https://packagist.org/packages/justblackbird/amphp-priority-emitter)[ RSS](/packages/justblackbird-amphp-priority-emitter/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (7)Versions (5)Used By (0)

AMP priority emitter
====================

[](#amp-priority-emitter)

[![Latest Stable Version](https://camo.githubusercontent.com/3316ddb0fe5ac992a76d9f1aa23b171e88d574c93f7aa95ea09a7d35f2bf75ca/68747470733a2f2f706f7365722e707567782e6f72672f6a757374626c61636b626972642f616d7068702d7072696f726974792d656d69747465722f76)](//packagist.org/packages/justblackbird/amphp-priority-emitter) [![Test](https://github.com/JustBlackBird/amphp-priority-emitter/workflows/Test/badge.svg)](https://github.com/JustBlackBird/amphp-priority-emitter/workflows/Test/badge.svg)

> In-memory implementation of async emitter with prioritized messages

Why
---

[](#why)

Implementation of AMP Emitter is backed by a queue. It covers many cases but sometimes a priority queue is needed.

For example, you're building a bot for a social network or a messenger. Assume that the bot can react for users' commands and broadcast information to all its subscribers. These two types of messages have different priorities. Commands' responses must be sent as soon as possible to keep UX responsive but broadcasting messages can wait for a while.

You can build the app around a message bus. There is some code that pushes messages to the bus, and some code that pull them out and transfer to social network API.

You cannot use Emitter shipped with AMP because in such case broadcasting messages will block command ones because there is no way to set priority with AMP Emitter.

This library adds and Emitter with API similar to AMP Emitter but with priority support.

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

[](#installation)

```
composer require justblackbird/amphp-priority-emitter

```

Usage
-----

[](#usage)

```
use Amp\Loop;
use JustBlackBird\AmpPriorityEmitter\Emitter;

// The following example will output:
// - important message
// - message one
// - message two

Loop::run(static function() {
    $emitter = new Emitter();

    $emitter->emit('message one', 0);
    $emitter->emit('message two', 0);
    $emitter->emit('important message', 5);
    $emitter->complete();

    $iterator = $emitter->iterate();
    while(yield $iterator->advance()) {
        echo "- " . $iterator->getCurrent() . "\n";
    }
});
```

License
-------

[](#license)

[MIT](http://opensource.org/licenses/MIT) (c) Dmitry Simushev

The implementation is based on [AMP Emitter](https://amphp.org/amp/iterators/#emitter).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~9 days

Total

4

Last Release

2089d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a2b12a708d5649504df9322541ff13341f5968995c7ea2f8f83a1d19692edf26?d=identicon)[justblackbird](/maintainers/justblackbird)

---

Top Contributors

[![JustBlackBird](https://avatars.githubusercontent.com/u/1167086?v=4)](https://github.com/JustBlackBird "JustBlackBird (24 commits)")

---

Tags

amphpphp

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/justblackbird-amphp-priority-emitter/health.svg)

```
[![Health](https://phpackages.com/badges/justblackbird-amphp-priority-emitter/health.svg)](https://phpackages.com/packages/justblackbird-amphp-priority-emitter)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[react/react

ReactPHP: Event-driven, non-blocking I/O with PHP.

9.1k3.6M63](/packages/react-react)[reactivex/rxphp

Reactive extensions for php.

1.7k3.2M49](/packages/reactivex-rxphp)[amphp/process

A fiber-aware process manager based on Amp and Revolt.

25552.6M52](/packages/amphp-process)[amphp/parallel-functions

Parallel processing made simple.

27910.3M26](/packages/amphp-parallel-functions)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)

PHPackages © 2026

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