ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
* [ ] 本次示例以 [thinkphp5](https://www.kancloud.cn/manual/thinkphp5/118003) 做示例 1. 首先在宝塔中添加站点,下载 tp5 源码安装进去 ![](https://img.kancloud.cn/c9/1d/c91d8b0a21522069ddb48bf6c753aad7_741x606.png) ![](https://img.kancloud.cn/50/fd/50fdfc419c9ab3e5eb7d9cb2c8fa9a6f_1554x789.png) 2. 下载 GateIm,建议使用 composer 运行 composer require xiehaohong/gateim,提示下方内容则代表已经安装成功 若提示其他内容,则为安装失败,请检测comoiser是否安装 ~~~ // 安装命令 composer require xiehaohong/gateim ~~~ ![](https://img.kancloud.cn/db/b4/dbb492a7cf832eda1c41b1da45676e81_1553x695.png) ![](https://img.kancloud.cn/e9/db/e9db56193f59d92f798607dc4e82a8b1_758x219.png) 3. 由于GateIm 是在 cli 命令行模式下运行的,所以需要创建自定义命令行 * 第一步,配置command.php文件,目录在application/command.php ``` return [ 'app\index\command\GateIm', ]; ``` * 第二步,建立命令类文件,新建application/index/command/GateIm.php ``` <?php namespace app\index\command; use gateim\library\server\Swooles; use think\console\Command; use think\console\Input; use think\console\Output; class GateIm extends Command { protected function configure() { $this->setName('gateim')->setDescription('Here is the remark '); } protected function execute(Input $input, Output $output) { new Swooles(); } } ``` 4. 打开服务,出现这个信息代表运行成功 ![](https://img.kancloud.cn/2d/38/2d38d53acc22fc70a0abb223cefa11ad_1000x687.png) 5. 前端测试是否可以连接成功 websocket在线测试地址:[http://www.websocket-test.com/](http://www.websocket-test.com/) ![](https://img.kancloud.cn/26/d1/26d17ff85e798e22f538f2e28af7bb40_1536x820.png) 7. 要在项目中对连接的客户端做如发送信息等操作,看后面调用方法中的 [【fd,uid,group_id 关系】](fd%EF%BC%8Cuid%EF%BC%8Cgroup_id%E5%85%B3%E7%B3%BB.md) [【发送操作请求】](%E5%8F%91%E9%80%81%E6%93%8D%E4%BD%9C%E8%AF%B7%E6%B1%82.md) [【提供方法】](%E6%8F%90%E4%BE%9B%E6%96%B9%E6%B3%95.md) ![](https://img.kancloud.cn/0c/ff/0cffaffcfa978ad6b71250193dd154d7_1196x590.png)