百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

web-msg-sender

> 编程语言
开源

基于 workerman 编写的 PHP 语言的 Web 消息推送器。

928 stars0 点赞4 次浏览
访问官网GitHub

工具介绍

基于 workerman 编写的 PHP 语言的 Web 消息推送器。

web-msg-sender

Web消息实时推送,支持在线用户数实时统计。基于PHPSocket.IO开发,使用websocket推送数据,当浏览器不支持websocket时自动切换comet推送数据。

效果截图

线上demo

接收消息页面:http://www.workerman.net:2123/
后端推送接口url:http://www.workerman.net:2121/?type=publish&to=&content=msgcontent
to为接收消息的uid,如果不传递则向所有人推送消息
content 为消息内容

注:可以通过php或者其它语言的curl功能实现后台推送

下载安装

1、git clone https://github.com/walkor/web-msg-sender

2、composer install

后端服务启动停止

Linux系统

启动服务

php start.php start -d

停止服务

php start.php stop

服务状态

php start.php status

windows系统

双击start_for_win.bat

如果启动不成功请参考 Workerman手册 配置环境

前端代码类似:

javascript
// 引入前端文件

后端调用api向任意用户推送数据

php
 'publish',
   'content' => '这个是推送的测试数据',
   'to' => $to_uid, 
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $push_api_url );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, array("Expect:"));
$return = curl_exec ( $ch );
curl_close ( $ch );
var_export($return);

常见问题:

如果通信不成功检查防火墙
/sbin/iptables -I INPUT -p tcp --dport 2120 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 2121 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 2123 -j ACCEPT

workerman相关参见 www.workerman.net

workerman更多有趣的应用:

小蝌蚪聊天室

多人在线flappy birds

其它

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPrealtime-messagingwebsocketworkerman

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言