PHPackages                             johnnylei/message-system - 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. johnnylei/message-system

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

johnnylei/message-system
========================

Yii2 message system

1.15(8y ago)17348[2 issues](https://github.com/johnnylei/message_system/issues)MITPHPPHP &gt;=5.4.0

Since May 6Pushed 8y ago2 watchersCompare

[ Source](https://github.com/johnnylei/message_system)[ Packagist](https://packagist.org/packages/johnnylei/message-system)[ Docs](https://github.com/johnnylei/message_system.git)[ RSS](/packages/johnnylei-message-system/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (1)Versions (8)Used By (0)

message\_system
===============

[](#message_system)

这是一个基于yii2的消息系统

install
-------

[](#install)

```
composer require --prefer-dist johnnylei/message-system

```

usage
-----

[](#usage)

### imgrate

[](#imgrate)

打开imgrate/文件夹，建好相关的表

### 配置文件

[](#配置文件)

```
'messageManager'=>[
    'class'=>'johnnylei\message_system\MessageManager',
    // userInformation 是一个用户表的activeRecord,主要作用当你发送消息的时候，将用户表里面的消息总数＋１，当你阅读完消息的时候，将用户表里面的消息数－１，
    // 通过实现UserInformationInterface,里面的两个方法
    'userInformation'=>[
        'class'=>'xxx',
    ]
]

```

### 监听一个队列

[](#监听一个队列)

```
// 原理就是往message_queue_subscription表里面插入一条数据，表示某个用户监听了某个队列
$subscription = new MessageQueueSubscription();
$subscription->subscription($userId, $queueId);

```

### 发送消息

[](#发送消息)

```
// 发送消息就是往某个消息队列里面写数据，谁监听了这个消息队列，谁就会收到一条数据
// 原理，１.生产一条消息记录，２.在message_queue_subscription表里面查看谁监听了这个队列 3.根据获取到的user_id,将第一步生成消息id,和user_id写入到message_user_map表里面，这样就表示该用户收到这条消息了
Yii::$app->messageManager->send([
                'title'=> 'this is title',
                'body'=> 'this is body',
                // 后面的参数不重要，但是可以配置
                // type就是你自定义一个消息type
                'type'=>'this is message type',
                // 这个参数也是你自定的显示风格，我们用到的弹窗和打开新的页面，具体怎么用，自己写规则
                'show_style'=>'this is show style',
            ], $queue_id);

```

### 接受消息

[](#接受消息)

```
// 获取所有消息的列表
$messageList = Yii::$app->messageManager->myMessageList();

// 获取一个消息
$messageList = Yii::$app->messageManager->receive();

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~20 days

Recently: every ~30 days

Total

7

Last Release

3221d ago

### Community

Maintainers

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

---

Top Contributors

[![Johnny539](https://avatars.githubusercontent.com/u/237241768?v=4)](https://github.com/Johnny539 "Johnny539 (6 commits)")

---

Tags

messageyii2

### Embed Badge

![Health badge](/badges/johnnylei-message-system/health.svg)

```
[![Health](https://phpackages.com/badges/johnnylei-message-system/health.svg)](https://phpackages.com/packages/johnnylei-message-system)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[mikemadisonweb/yii2-rabbitmq

Wrapper based on php-amqplib to incorporate messaging in your Yii2 application via RabbitMQ. Inspired by RabbitMqBundle for Symfony 2, really awesome package.

74272.6k1](/packages/mikemadisonweb-yii2-rabbitmq)[ignatenkovnikita/yii2-queuemanager

Yii2 Queue Manager

2063.4k2](/packages/ignatenkovnikita-yii2-queuemanager)

PHPackages © 2026

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