博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
websocket 框架_PHP微服务框架Swoft:WebSocket服务器第1部分
阅读量:2511 次
发布时间:2019-05-11

本文共 2752 字,大约阅读时间需要 9 分钟。

websocket 框架

This article we are going to learn is: How to install and run the swoft websocket server.

我们将要学习的这篇文章是:如何安装和运行swoft websocket服务器。

This article is one of a series of articles on the Swoft WebSocket Server. Let's learn about Swoft!
本文是Swoft WebSocket服务器上一系列文章之一。 让我们了解Swoft!

斯沃夫特是什么? (What is Swoft?)

Swoft is a PHP high performance microservice coroutine framework. It has been published for many years and has become the best choice for php.

Swoft是一个PHP高性能微服务协程框架。 它已经发布了很多年,并已成为php的最佳选择。

It can be like Go, built-in coroutine web server and common coroutine client and is resident in memory, independent of traditional PHP-FPM.

它可以像Go,内置的协程Web服务器和通用协程客户端一样,驻留在内存中,独立于传统PHP-FPM。

There are similar Go language operations, similar to the Spring Cloud framework flexible annotations.

有类似的Go语言操作,类似于Spring Cloud框架的灵活注释。

Through three years of accumulation and direction exploration, Swoft has made Swoft the Spring Cloud in the PHP world, which is the best choice for PHP's high-performance framework and microservices management.

通过三年的积累和方向探索,Swoft使Swoft成为了PHP世界中的Spring Cloud,它是PHP高性能框架和微服务管理的最佳选择。

Github (Github)

建立新专案 (Create new project)

Use swoft-cli tool to create new project for Websocket.

使用swoft-cli工具为Websocket创建新项目。

php swoftcli.phar create:app --type ws swoft-ws-appcd swoft-ws-appcomposer install

启动服务器 (Start server)

Start Websocket server with php bin/swoft ws:start command, you can see below:

php bin/swoft ws:start命令启动Websocket服务器,如下所示:

$ php bin/swoft ws:start                                      Information Panel  *******************************************************************************************  * WebSocket | Listen: 0.0.0.0:18308, type: TCP, mode: Process, worker: 8  *******************************************************************************************
18308
18308

模组 (Module)

Use swoft-cli tool to create new websocket module.

使用swoft-cli工具创建新的websocket模块。

php swoftcli.phar gen:ws-mod echo --prefix /echo

Code for echo module(app/WebSocket/EchoModule.php) like this:

回声模块( app/WebSocket/EchoModule.php )的代码如下:

push($fd, 'hello, welcome! :)'); }}

测试 (Test)

Here use swoft-devtool to connect WebSocket server.

在这里使用swoft-devtool连接WebSocket服务器。

Use php bin/swoft dclient:ws /echo command in swoft-devtool component to connect WebSocket server, you can see connection success message like below.

swoft-devtool组件中使用php bin/swoft dclient:ws /echo命令连接WebSocket服务器,可以看到如下所示的连接成功消息。

Begin connecting to websocket server: 127.0.0.1:18308 path: /echoSuccess connect to websocket server. Now, you can send messageINTERACTIVE================================================================================server> ?Opened, welcome #1!client> hiserver> Recv: hiclient>

Github (Github)

翻译自:

websocket 框架

转载地址:http://xzdwd.baihongyu.com/

你可能感兴趣的文章
使用Postmark测试后端存储性能
查看>>
NSTextView 文字链接的定制化
查看>>
第五天站立会议内容
查看>>
CentOs7安装rabbitmq
查看>>
(转))iOS App上架AppStore 会遇到的坑
查看>>
解决vmware与主机无法连通的问题
查看>>
做好产品
查看>>
项目管理经验
查看>>
笔记:Hadoop权威指南 第8章 MapReduce 的特性
查看>>
JMeter响应数据出现乱码的处理-三种解决方式
查看>>
获取设备实际宽度
查看>>
Notes on <High Performance MySQL> -- Ch3: Schema Optimization and Indexing
查看>>
Alpha冲刺(10/10)
查看>>
数组Array的API2
查看>>
为什么 Redis 重启后没有正确恢复之前的内存数据
查看>>
No qualifying bean of type available问题修复
查看>>
第四周助教心得体会
查看>>
spfile
查看>>
Team Foundation Service更新:改善了导航和项目状态速查功能
查看>>
WordPress资源站点推荐
查看>>