Download the PHP package hyperf/socketio-server without Composer

On this page you can find all versions of the php package hyperf/socketio-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package socketio-server

Socket.io是一款非常流行的应用层实时通讯协议和框架,可以轻松实现应答、分组、广播。hyperf/socketio-server支持了Socket.io的WebSocket传输协议。

安装

hyperf/socketio-server 是基于WebSocket实现的,请确保服务端已经添加了WebSocket服务配置。

快速开始

服务端

每个 socket 会自动加入以自己 sid 命名的房间($socket->getSid()),发送私聊信息就推送到对应 sid 即可。

框架会触发 connectdisconnect 两个事件。

客户端

由于服务端只实现了WebSocket通讯,所以客户端要加上 {transports:["websocket"]}

API 清单

进阶教程

设置 Socket.io 命名空间

Socket.io 通过自定义命名空间实现多路复用。(注意:不是 PHP 的命名空间)

  1. 可以通过 @SocketIONamespace("/xxx") 将控制器映射为 xxx 的命名空间,

  2. 也可通过

在路由中添加。

开启 Session

安装并配置好 hyperf/session 组件及其对应中间件,再通过 SessionAspect 切入 SocketIO 来使用 Session 。

swoole 4.4.17 及以下版本只能读取 http 创建好的Cookie,4.4.18 及以上版本可以在WebSocket握手时创建Cookie

调整房间适配器

默认的房间功能通过 Redis 适配器实现,可以适应多进程乃至分布式场景。

  1. 可以替换为内存适配器,只适用于单 worker 场景。

  2. 可以替换为空适配器,不需要房间功能时可以降低消耗。

调整 SocketID (sid)

默认 SocketID 使用 ServerID#FD 的格式,可以适应分布式场景。

  1. 可以替换为直接使用 Fd 。

  2. 也可以替换为 SessionID 。

其他事件分发方法

  1. 可以手动注册事件,不使用注解。

  2. 可以在控制器上添加 @Event() 注解,以方法名作为事件名来分发。此时应注意其他公有方法可能会和事件名冲突。

All versions of socketio-server with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-json Version *
ext-redis Version *
hyperf/codec Version ~3.1.0
hyperf/collection Version ~3.1.0
hyperf/di Version ~3.1.0
hyperf/redis Version ~3.1.0
hyperf/websocket-server Version ~3.1.0
psr/container Version ^1.0|^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hyperf/socketio-server contains the following files

Loading the files please wait ....