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
Requires
- php: ^8.1
- chrisullyott/php-filesize: ^4.2
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- easycorp/easyadmin-bundle: ^4
- psr/log: ^3|^2|^1
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/event-dispatcher-contracts: ^2.5 | ^3
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/doctrine-indexed-bundle: 0.0.*
- tourze/doctrine-snowflake-bundle: 0.0.*
- tourze/doctrine-timestamp-bundle: 0.0.*
- tourze/easy-admin-attribute: 0.1.*
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-05-11 17:46:46 UTC
README
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
andMessageStatus
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.