PHPackages                             tourze/socket-io-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. tourze/socket-io-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

tourze/socket-io-bundle
=======================

Socket.IO implementation for Symfony applications with real-time communication support

0.3.0(4mo ago)03MITPHPCI passing

Since Apr 26Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/socket-io-bundle)[ Packagist](https://packagist.org/packages/tourze/socket-io-bundle)[ RSS](/packages/tourze-socket-io-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (43)Versions (7)Used By (0)

Socket.IO Bundle
================

[](#socketio-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![PHP Version](https://camo.githubusercontent.com/d70800555aaeb68ad58125c3f16ba45594e13539fab6653948943b2dd2c8ef76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f736f636b65742d696f2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/socket-io-bundle)[![Latest Version](https://camo.githubusercontent.com/15696beaccb9fb5aedb0d98595346eacbe21a2c5b99fd68b4ec36dbf5cc812d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f736f636b65742d696f2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/socket-io-bundle)[![License](https://camo.githubusercontent.com/d1075a98604354cb8d0a9c828a9a0770c6bd237b4a38bdac2143ba6c04714071/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f736f636b65742d696f2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/socket-io-bundle)[![Build Status](https://camo.githubusercontent.com/31e74420c862bc880189eee9114ca161b8d90e68ed87d7eff7f1f6f1c7f9dc2f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f75727a652f736f636b65742d696f2d62756e646c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/tourze/socket-io-bundle)[![Code Coverage](https://camo.githubusercontent.com/683f7a830e2ef8026e2a5cac319b32a28f5605970b9b9d96bce06e0539b6d47e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f746f75727a652f736f636b65742d696f2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/socket-io-bundle)[![Total Downloads](https://camo.githubusercontent.com/d74fd735aac08713618a90c33265d616e43a35e9eb61824d1069e8c0e1c2db5b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f736f636b65742d696f2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/socket-io-bundle)

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.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Dependencies](#dependencies)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Advanced Usage](#advanced-usage)
- [Commands](#commands)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
- [Changelog](#changelog)

Features
--------

[](#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
------------

[](#installation)

```
composer require tourze/socket-io-bundle
```

Configuration
-------------

[](#configuration)

Set these in your `.env`:

```
SOCKET_IO_PING_INTERVAL=25000
SOCKET_IO_PING_TIMEOUT=20000
SOCKET_IO_MAX_PAYLOAD_SIZE=1000000
```

Quick Start
-----------

[](#quick-start)

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

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

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

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

3. 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));
```

Dependencies
------------

[](#dependencies)

This bundle requires the following:

**PHP Requirements:**

- PHP &gt;= 8.1

**Symfony Requirements:**

- Symfony &gt;= 7.3
- Doctrine ORM &gt;= 3.0
- EasyAdmin Bundle &gt;= 4.0

**Core Dependencies:**

- `doctrine/orm`: ^3.0
- `doctrine/doctrine-bundle`: ^2.13
- `easycorp/easyadmin-bundle`: ^4
- `symfony/framework-bundle`: ^7.3
- `symfony/console`: ^7.3

Usage
-----

[](#usage)

### Basic Client Connection

[](#basic-client-connection)

```
const socket = io('http://localhost:8000/socket.io/');

// Join a room
socket.emit('joinRoom', 'room-1');

// Leave a room
socket.emit('leaveRoom', 'room-1');

// Get room list
socket.emit('getRooms');

// Listen for room updates
socket.on('roomList', rooms => console.log(rooms));
```

### Server-Side Broadcasting

[](#server-side-broadcasting)

```
use SocketIoBundle\Service\MessageService;

class NotificationService
{
    public function __construct(
        private MessageService $messageService
    ) {}

    public function broadcastToRoom(string $roomName, string $event, array $data): void
    {
        $this->messageService->sendToRooms([$roomName], $event, $data);
    }
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Room Logic

[](#custom-room-logic)

Extend the `RoomService` to implement custom room behavior:

```
use SocketIoBundle\Service\RoomService;

class CustomRoomService extends RoomService
{
    public function joinRoom(Socket $socket, string $roomName): void
    {
        // Custom logic before joining
        parent::joinRoom($socket, $roomName);
        // Custom logic after joining
    }
}
```

### Message Delivery Status

[](#message-delivery-status)

Monitor message delivery using the `DeliveryService` and `MessageStatus` enum:

```
use SocketIoBundle\Service\DeliveryService;
use SocketIoBundle\Enum\MessageStatus;

class MyService
{
    public function __construct(
        private DeliveryService $deliveryService
    ) {}

    public function checkDeliveryStatus(string $messageId): MessageStatus
    {
        return $this->deliveryService->getMessageStatus($messageId);
    }
}
```

### Persistent Message History

[](#persistent-message-history)

Access message history via Doctrine entities:

```
use SocketIoBundle\Repository\MessageRepository;

class MessageHistoryService
{
    public function __construct(
        private MessageRepository $messageRepository
    ) {}

    public function getRoomHistory(string $roomName, int $limit = 50): array
    {
        return $this->messageRepository->findByRoomName($roomName, $limit);
    }
}
```

Commands
--------

[](#commands)

### Heartbeat Command

[](#heartbeat-command)

Execute Socket.IO heartbeat check and resource cleanup:

```
php bin/console socket-io:heartbeat [--daemon] [--interval=25000]
```

**Options:**

- `--daemon` (`-d`): Run in daemon mode
- `--interval=25000` (`-i`): Heartbeat interval in milliseconds (default: 25000)

This command:

- Checks active connections and removes expired ones
- Cleans up expired deliveries and messages
- Broadcasts alive events to active connections
- Can run continuously in daemon mode

### Cleanup Deliveries Command

[](#cleanup-deliveries-command)

Clean up expired message delivery records:

```
php bin/console socket:cleanup-deliveries [--days=7] [--daemon] [--interval=3600]
```

**Options:**

- `--days=7` (`-d`): Retention period in days (default: 7)
- `--daemon`: Run in daemon mode
- `--interval=3600` (`-i`): Cleanup interval in seconds (default: 3600)

This command removes delivery records older than the specified number of days. It can run once or continuously in daemon mode for automated cleanup.

Testing
-------

[](#testing)

Run the test suite:

```
phpunit
```

Run with coverage:

```
phpunit --coverage-html coverage/
```

Contributing
------------

[](#contributing)

PRs and issues welcome! Please follow PSR-12 and Symfony best practices.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin feature/my-new-feature`)
5. Create a new Pull Request

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE).

Changelog
---------

[](#changelog)

See [Releases](https://packagist.org/packages/tourze/socket-io-bundle#releases) for version history.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance74

Regular maintenance activity

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Recently: every ~58 days

Total

6

Last Release

147d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-socket-io-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-socket-io-bundle/health.svg)](https://phpackages.com/packages/tourze-socket-io-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
