PHPackages                             perry/msg-swoole - 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. perry/msg-swoole

ActiveLibrary

perry/msg-swoole
================

msg-swoole

00PHP

Since Apr 26Pushed 6y ago1 watchersCompare

[ Source](https://github.com/yangguangpeng/msg-swoole)[ Packagist](https://packagist.org/packages/perry/msg-swoole)[ RSS](/packages/perry-msg-swoole/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

 msg-swoole
============

[](#-msg-swoole-)

 msg-swoole.

\###功能 实现实时推送消息到客户端

环境准备
----

[](#环境准备)

```
1.安装redis拓展
pecl install redis
如果报错：Cannot find igbinary.h，执行 pecl install igbinary命令
2.安装swoole拓展
pecl install swoole

```

安装和使用
-----

[](#安装和使用)

1.下载

```
$ composer require perry/msg-swoole
```

2.配置上服务提供者 Perry\\MsgSwoole\\SwooleServiceProvider::class

3.生成配置文件 php artisan vendor:publish --provider="Perry\\MsgSwoole\\SwooleServiceProvider"

4.发布信息

```
参数：
$receiver_id：接受者id，（这里的$receiver_id是明文）
$content：发布的内容

a.门面模式调用

在app.php加上alias加上门面别名配置：'MsgPublish'=>Perry\MsgSwoole\Facades\PublishFacades::class
代码：\MsgPublish::setReceiver($receiver_id)->publish($content);

b.服务容器调用
代码：app('msg-swoole.publish')->setReceiver($receiver_id)->publish($content)

```

5.启动websocket服务 php artisan msg:swoole start

6.演示demo路由，路由前缀是msg-swoole

Route::get('/', 'DemoController@show');

Route::get('/publish', 'DemoController@publish');

安全考虑,对来自客户端的$receiver\_id进行加密
-----------------------------

[](#安全考虑对来自客户端的receiver_id进行加密)

1.开启配置文件 'channel'=&gt;\[ //是否验证客户端的信息，默认开启 'is\_verification'=&gt;true \]

2.安装原生jwt: github地址：

3.加密$receiver\_id后发给客户端 app('msg-swoole.encryption')-&gt;encrypt($receiver\_id);

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/perry/msg-swoole/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/perry/msg-swoole/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![yangguangpeng](https://avatars.githubusercontent.com/u/29401826?v=4)](https://github.com/yangguangpeng "yangguangpeng (14 commits)")

### Embed Badge

![Health badge](/badges/perry-msg-swoole/health.svg)

```
[![Health](https://phpackages.com/badges/perry-msg-swoole/health.svg)](https://phpackages.com/packages/perry-msg-swoole)
```

PHPackages © 2026

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