Download the PHP package kode/messaging without Composer

On this page you can find all versions of the php package kode/messaging. 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 messaging

kode/messaging

统一消息层 | WebSocket / SSE / MQTT / UDP / Long-Polling / CoAP / NATS / STOMP / gRPC / WebTransport / RTMP | PHP 8.3+ | PSR 合规 | 可插拔适配器

PHP Version kode Version

简介

kode/messagingkode/* 家族中的统一消息层 Composer 包,封装 WebSocketSSEMQTTUDPLong-PollingCoAPNATSSTOMPgRPCWebTransportRTMP 等 11 种长连接 / 实时消息协议,提供一致的 API协议无关的消息抽象可插拔的扩展点

一个 Messaging::server() 启动所有协议,业务代码面向接口编程,不感知具体协议

特性

特性 说明
🌐 11 协议统一 WebSocket / SSE / MQTT / UDP / Long-Polling / CoAP / NATS / STOMP / gRPC / WebTransport / RTMP
🔌 可插拔适配器 新增协议不改动核心代码(3 步:Adapter / 注册 / 文档)
📡 协议无关 业务层只依赖 MessageInterface
🧩 中间件管道 鉴权 / 限流 / 编解码 / 校验 / 追踪
🏷️ 路由 基于 event / topic 路由消息
📢 统一 Pub/Sub 进程内 / 跨进程 / 跨节点(Redis)
🛡️ PSR 合规 PSR-3 / PSR-4 / PSR-7 / PSR-14 / PSR-18
协程友好 kode/fibers 协作,无 Fiber 自动降级
🔒 安全 TLS、JWT、Origin 校验、签名鉴权、限流
📊 可观测 事件、指标、结构化日志
🚀 高性能 Swoole / Swow / stream 多传输层
🔁 重连 / 心跳 客户端内置指数退避重连、ping/pong

安装

按需安装可选依赖:

快速开始

WebSocket

SSE

MQTT

客户端(连接外部 Broker):

Broker(内置 MQTT 3.1.1 服务端,支持 QoS 0/1/2、主题通配符、保留消息、遗嘱消息):

NATS(pub/sub、request/reply)

STOMP(消息队列客户端)

gRPC Streaming

WebTransport(HTTP/3 双工)

RTMP(直播源接入)

MQTT + WebSocket 组合(IoT 百万设备方案)

设备端(充电桩、手表等)用裸 MQTT(tcp://1883),用户端(App、网页管理后台)用 MQTT over WebSocket(ws://8083),两种客户端连同一个 Broker,消息互通。

浏览器端使用 MQTT.js 连接:

协议矩阵

协议 方案 服务端 客户端 适用
WebSocket ws:// / wss:// 浏览器长连接、聊天、游戏
SSE sse:// 服务端推送、通知、大屏
MQTT 3.1.1 / 5.0 mqtt:// / mqtts:// ✅ Broker IoT、移动推送、Pub/Sub
MQTT over WebSocket mqtt+ws:// / mqtt+wss:// App/网页管理后台、穿越防火墙
UDP / Datagram udp:// 实时音视频、游戏、广播
Long-Polling poll:// / http:// WebSocket 回退、低频推送
CoAP (RFC 7252) coap:// / coaps:// IoT 传感器、NB-IoT、LoRa
NATS nats:// ✅ 嵌入式 Broker 微服务 Pub/Sub、request/reply
STOMP 1.2 stomp:// ✅ 嵌入式 Broker 消息队列(兼容 RabbitMQ / ActiveMQ)
gRPC Streaming grpc:// 微服务 RPC、4 种流式调用
WebTransport wt:// / webtransport:// HTTP/3-fallback HTTP/3 双工(依赖 aioquic / msquic)
RTMP rtmp:// / rtmps:// 直播源接入(OBS / FMLE)

架构

传输层(多运行时兼容)

kode/messaging 通过 TransportInterface 抽象底层 socket 操作,支持 5 种传输驱动:

驱动 依赖 性能 说明
stream 零依赖(内置) 基准 纯 PHP stream_socket_*,始终可用
sockets ext-sockets +20-50% 底层 socket 扩展
swoole ext-swoole 100x Swoole 协程,百万级并发
swow ext-swow 100x Swow 协程,跨平台
workerman workerman/workerman 50x Workerman 事件循环,多进程

自动检测:配置 transport: auto 时,TransportFactory 按优先级自动选择: swoole > swow > workerman > stream。

与 kode/* 家族协作

场景 依赖包 协作方式
日志 kode/log 或 PSR-3 LoggerInterface 注入
协程 kode/fibers 长连接内启动 Fiber
事件 kode/event connection.open 等事件派发
上下文 kode/context 连接 ID、追踪
队列 kode/queue MQTT QoS 1/2 落地
进程 kode/process 多 Worker、集群
缓存 kode/cache 会话、广播订阅
HTTP kode/http / nyholm/psr7 SSE 复用 HTTP
HTTP 客户端 kode/http-client 长轮询回退
鉴权 kode/jwt JWT 鉴权中间件

PHP 8.3 / 8.4 / 8.5 兼容

支持的现代特性(通过 PhpCompat / RuntimeDetector 运行时检测,自动降级):

特性 用法 版本 降级方案
readonly class 不可变消息体 ≥ 8.2(基线已含)
enum 协议状态机 ≥ 8.1
Fibers 协程 ≥ 8.1
json_validate() JSON 快速校验 ≥ 8.3 json_decode + json_last_error
Random\Randomizer 安全随机 ≥ 8.3 random_bytes()
typed class constants 协议常量 ≥ 8.3 普通 const(当前使用)
#[\Override] 覆盖标记 ≥ 8.3(基线)
property hooks 连接属性 ≥ 8.4 传统 getter/setter
pipe operator \|> 链式构造 ≥ 8.5 Kode::pipe() foreach 模拟

文档

示例

许可证

Apache-2.0

  1. 最低是PHP8.3+版本。相关的文档都要更新。
  2. 本包做好安全性,便捷开发,mqtt3+、5+版本实现相关功能。
  3. 相关服务端、客户端等 健壮性 架构规划和代码实现。
  4. 修补优化升级增强功能。

All versions of messaging with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-json Version *
ext-mbstring Version *
kode/limiting Version ^2.0
psr/log Version ^2.0|^3.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 kode/messaging contains the following files

Loading the files please wait ...