snoke/ws-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

snoke/ws-bundle

最新稳定版本:v0.1.2

Composer 安装命令:

composer require snoke/ws-bundle

包简介

README 文档

README

Symfony bundle for the Snoke WebSocket Gateway stack.

This repository contains only the Symfony integration (publishers, presence, inbox consumer, token helper). To run a full local stack (gateway + brokers), use the gateway repo: https://github.com/snoke/Symfony-Python-Realtime-Stack

Requirements

  • PHP >= 8.4
  • Symfony ^8.0

Install

composer require snoke/ws-bundle:0.1.2

If you want the latest changes, use dev-main.

Note: the bundle depends on open-telemetry/transport-grpc, which requires the PHP grpc extension. For local dev you can either install ext-grpc or use:

composer install --ignore-platform-req=ext-grpc

If you are not using Symfony Flex, ensure the bundle is registered in config/bundles.php:

return [
  Snoke\WsBundle\SnokeWsBundle::class => ['all' => true],
];

Configuration

Create config/packages/snoke_ws.yaml in your Symfony app:

snoke_ws:
  mode: '%env(default:ws_mode_default:WS_MODE)%'
  transport:
    type: '%env(default:ws_transport_type_default:WS_TRANSPORT_TYPE)%'
    http:
      base_url: '%env(resolve:default::WS_GATEWAY_BASE_URL)%'
      publish_path: '/internal/publish'
      timeout_seconds: 5
      auth:
        type: api_key
        header: 'X-Api-Key'
        value: '%env(resolve:default::WS_GATEWAY_API_KEY)%'
    redis_stream:
      dsn: '%env(resolve:default::WS_REDIS_DSN)%'
      stream: '%env(resolve:default::WS_REDIS_STREAM)%'
  presence:
    type: '%env(default:ws_presence_type_default:WS_PRESENCE_TYPE)%'
    http:
      base_url: '%env(resolve:default::WS_GATEWAY_BASE_URL)%'
      list_path: '/internal/connections'
    redis:
      dsn: '%env(resolve:default::WS_REDIS_DSN)%'
      prefix: '%env(resolve:default::WS_REDIS_PREFIX)%'
  events:
    type: '%env(default:ws_events_type_default:WS_EVENTS_TYPE)%'
    redis_stream:
      dsn: '%env(resolve:default::WS_REDIS_DSN)%'
      stream: '%env(resolve:default::WS_REDIS_EVENTS_STREAM)%'
  subjects:
    user_prefix: 'user:'

Defaults:

  • terminator mode uses HTTP publish + webhook events
  • core mode uses Redis streams

Core mode consumer

In core mode you must run a consumer that reads ws.inbox and dispatches events:

php bin/console ws:consume

You can run this as a separate service in Docker Compose.

Demo token helper (optional)

The bundle includes a demo token service for quick local testing:

use Snoke\WsBundle\Service\DemoTokenService;

public function token(DemoTokenService $tokens): Response
{
    [$jwt, $error] = $tokens->issue('42');
    // return token to the frontend
}

Gateway stack

To start the gateway + brokers stack, use the gateway repo: https://github.com/snoke/Symfony-Python-Realtime-Stack

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固