PHPackages                             nineinchnick/yii2-nfy - 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. nineinchnick/yii2-nfy

ActiveYii2-module[Queues &amp; Workers](/categories/queues)

nineinchnick/yii2-nfy
=====================

A generic message queue interface with various implementations for the Yii 2.0 framework. Basic interface included.

v0.9.0(11y ago)5978911[7 issues](https://github.com/nineinchnick/yii2-nfy/issues)MITPHPPHP &gt;=5.4.0

Since Feb 27Pushed 9y ago20 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Notifications
=============

[](#notifications)

This is a module for [Yii 2.0 framework](http://www.yiiframework.com/) that provides:

- a generic queue component
- a Publish/Subscribe message delivery pattern
- a SQL database queue implementation
- a configurable way to send various notifications, messages and tasks to a queue
- a basic widget to read such items from queue and display them to the user as system notifications
- a basic widget to put in a navbar that displays notifications and/or messages in a popup
- a basic CRUD to manage and/or debug queues or use as a simple messanger

Messages could be passed directly as strings or created from some objects, like Active Records. This could be used to log all changes to the models, exactly like the [audittrail2](http://www.yiiframework.com/extension/audittrail2) extension.

When recipients are subscribed to a channel, message delivery can depend on category filtering, much like in logging system provided by the framework.

A simple SQL queue implementation is provided if a MQ server is not available or not necessary.

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

[](#installation)

1. Install [Yii2](https://github.com/yiisoft/yii2/tree/master/apps/basic) using your preferred method
2. Install package via [composer](http://getcomposer.org/download/)

- Run `php composer.phar require nineinchnick/yii2-nfy "dev-master"` OR add to composer.json require section `"nineinchnick/yii2-nfy": "dev-master"`
- If Redis queue will be used, also install "yiisoft/yii2-redis"

3. Update config file *config/web.php* as shown below. Check out the Module for more available options.

Enable module in configuration. Do it in both main and console configs, because some settings are used in migrations.

Copy migrations to your migrations folder and adjust dates in file and class names. Then apply migrations.

Define some queues as application components and optionally enable the module, see the next section.

```
$config = [
    // .........
	'aliases' => [
		'@nineinchnick/nfy' => '@vendor/nineinchnick/yii2-nfy',
	],
	'modules' => [
		'nfy' => [
			'class' => 'nineinchnick\nfy\Module',
		],
	],
	'components' => [
		'dbmq' => [
			'class' => 'nineinchnick\nfy\components\DbQueue',
			'id' => 'queue',
			'label' => 'Notifications',
			'timeout' => 30,
		],
		'sysvmq' => [
			'class' => 'nineinchnick\nfy\components\SysVQueue',
			'id' => 'a',
			'label' => 'IPC queue',
		],
		'redismq' => [
			'class' => 'nineinchnick\nfy\components\RedisQueue',
			'id' => 'mq',
			'label' => 'Redis queue',
			'redis' => 'redis',
		],
		// ..........
	],
]
```

Then you can send and receive messages through this component:

```
// send one message 'test'
Yii::$app->dbmq->send('test');
// receive all available messages without using subscriptions and immediately delete them from the queue
$messages = $queue->receive();
```

Or you could subscribe some users to it:

```
Yii::$app->queue->subscribe(Yii:$app->user->getId());
// send one message 'test'
Yii::$app->queue->send('test');
// receive all available messages for current user and immediately delete them from the queue
$messages = $queue->receive(Yii:$app->user->getId());
// if there are any other users subscribed, they will receive the message independently
```

Module parameters
-----------------

[](#module-parameters)

By specifying the users model class name in the *userClass* property proper table name and primary key column name will be used in migrations.

Display notifications
---------------------

[](#display-notifications)

Put anywhere in your layout or views or controller.

```
$this->widget('nfy.extensions.webNotifications.WebNotifications', array('url'=>$this->createUrl('/nfy/default/poll', array('id'=>'queueComponentId'))));
```

Receiving messages
------------------

[](#receiving-messages)

By configuring the WebNotifications widget messages could be read by:

- polling using ajax (repeating requests at fixed interval) an action that checks a queue and returns new items
- connect to a web socket and wait for new items

Changelog
---------

[](#changelog)

### 0.95 - 2014-01-15

[](#095---2014-01-15)

Initial release after porting from Yii 1.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.6% 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 ~0 days

Total

2

Last Release

4093d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/795177?v=4)[Jan Waś](/maintainers/nineinchnick)[@nineinchnick](https://github.com/nineinchnick)

---

Top Contributors

[![nineinchnick](https://avatars.githubusercontent.com/u/795177?v=4)](https://github.com/nineinchnick "nineinchnick (28 commits)")[![mozarcik](https://avatars.githubusercontent.com/u/1579480?v=4)](https://github.com/mozarcik "mozarcik (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nineinchnick-yii2-nfy/health.svg)

```
[![Health](https://phpackages.com/badges/nineinchnick-yii2-nfy/health.svg)](https://phpackages.com/packages/nineinchnick-yii2-nfy)
```

###  Alternatives

[zhuravljov/yii2-queue-monitor

Yii2 Queue Analytics Module

102203.2k](/packages/zhuravljov-yii2-queue-monitor)[bubasuma/yii2-simplechat

A simple chat for your yii2 application

889.5k](/packages/bubasuma-yii2-simplechat)

PHPackages © 2026

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