Files
annnj-company 130c1026c4 first commit
2026-04-17 18:29:53 +08:00

33 lines
664 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
ThinkPHP 5.0 Workerman 扩展
===============
## 使用方法
首先创建控制器类并继承 think\worker\Server然后设置属性和添加回调方法
~~~
namespace app\index\controller;
use think\worker\Server;
use app\index\model\User;
class Worker extends Server
{
protected $socket = 'http://0.0.0.0:2346';
public function onMessage($connection,$data)
{
$user = User::get($data['get']['id']);
$connection->send(json_encode($user));
}
}
~~~
> 注意该示例使用了User模型操作仅仅作为参考。
在命令行启动服务端
~~~
php index.php index/Worker/start
~~~
在浏览器中进行客户端测试
http://127.0.0.1:2346/?id=1