Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
W

web-msg-sender

> 编程语言
Open source

Web message pusher written in PHP based on workerman.

928 stars0 likes4 views
WebsiteGitHub

About

Web message pusher written in PHP based on workerman.

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 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPrealtime-messagingwebsocketworkerman

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

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