tourze/socket-io-bundle

Socket.IO

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.1.0 2025-05-05 08:25 UTC

This package is auto-updated.

Last update: 2025-05-11 17:46:46 UTC


README

English | 中文

Latest Version Build Status Quality Score Total Downloads

A Symfony bundle providing a full-featured Socket.IO server implementation for real-time, bidirectional communication. Supports room management, message delivery, namespaces, and persistent storage.

Features

  • Full Socket.IO server implementation (PHP, Symfony)
  • Room management (join/leave, auto-cleanup)
  • Message delivery, broadcast, and history
  • Namespace support
  • Auto-reconnect and heartbeat
  • Persistent storage (Doctrine ORM)
  • Extensible service layer

Installation

composer require tourze/socket-io-bundle

Requirements:

  • PHP >= 8.1
  • Symfony >= 6.4
  • Doctrine ORM

Quick Start

Register the bundle in your Symfony config if not using Flex.

// config/bundles.php
return [
    // ...
    SocketIoBundle\SocketIoBundle::class => ['all' => true],
];

Add the endpoint to your routes (if not using annotation routing):

# config/routes.yaml
socket_io:
  resource: '@SocketIoBundle/Controller/SocketController.php'
  type: annotation

Start the server and connect from your JS client:

const socket = io('http://localhost:8000/socket.io/');
socket.emit('joinRoom', 'room-1');
socket.on('roomList', rooms => console.log(rooms));

Configuration

Set these in your .env:

SOCKET_IO_PING_INTERVAL=25000
SOCKET_IO_PING_TIMEOUT=20000
SOCKET_IO_MAX_PAYLOAD_SIZE=1000000

Usage

  • Join/leave rooms: joinRoom, leaveRoom
  • Get room list: getRooms
  • Listen for roomList updates
  • Broadcast messages: use the MessageService or emit from server

Advanced

  • Custom room logic: extend RoomService
  • Message delivery status: see DeliveryService and MessageStatus enum
  • Persistent message history: via Doctrine entities

Contributing

PRs and issues welcome! Please follow PSR-12 and Symfony best practices. Run tests with:

phpunit

License

MIT License. See LICENSE.

Changelog

See Releases for version history.