PHPackages                             kim1ne/socket-server - 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. kim1ne/socket-server

ActiveLibrary

kim1ne/socket-server
====================

1.1.0(1y ago)215PHPPHP &gt;=8.1

Since Jan 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/kim1ne/socket-server)[ Packagist](https://packagist.org/packages/kim1ne/socket-server)[ RSS](/packages/kim1ne-socket-server/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Installation
============

[](#installation)

This package can be installed as a [Composer](https://getcomposer.org/) dependency.

```
composer require kim1ne/socket-server
```

The library uses libraries of the ReactPHP for async. Stream locks

### Supported protocols

[](#supported-protocols)

- WS - see [RFC6455](https://datatracker.ietf.org/doc/html/rfc6455)
- WSS
- TCP
- UDP
- TLS

### Usage

[](#usage)

- [Create server](https://github.com/kim1ne/socket-server/tree/main?tab=readme-ov-file#create-server-and-run)
- [Example: create server TLS/WSS](https://github.com/kim1ne/socket-server/tree/main?tab=readme-ov-file#example-create-server-tlswss)
- [Send message to all connected](https://github.com/kim1ne/socket-server/tree/main?tab=readme-ov-file#send-message-to-all-connected)
- [Send message to selected](https://github.com/kim1ne/socket-server/tree/main?tab=readme-ov-file#send-message-to-selected)
- [Set property for connection](https://github.com/kim1ne/socket-server/tree/main?tab=readme-ov-file#set-property-for-connection)

#### Create server and run

[](#create-server-and-run)

```
use Kim1ne\InputMessage;
use Kim1ne\Socket\Server\Connection;
use Kim1ne\Socket\Message;
use Kim1ne\Socket\Server\Server;
use Kim1ne\Socket\Server\Transport;

$server = new Server(transport: Transport::WS, port: 2346);

$server->on('connection', function (Connection $connection, Server $server) {
    InputMessage::green('Connected!')
});

$server->on('message', function (Message $message, Connection $connection, Server $server) {
    InputMessage::green("I've got the message!");
});

$server->on('close', function (Server $server) {
    InputMessage::green('Disconnected')
});

$server->on('error', function (\Throwable $throwable) {
    InputMessage::red('Error: ' . $throwable->getMessage());
});

$server->run();
```

#### Example: create server TLS/WSS

[](#example-create-server-tlswss)

```
use Kim1ne\Socket\Server\Server;
use Kim1ne\Socket\Server\Transport;

$server = new Server(transport: Transport::TLS, port: 2346, serverContext: [
        "ssl" => [
        "local_cert" => "./certs/server.crt",
        "local_pk" => "./certs/server.key",
        "verify_peer" => false,
        "crypto_method" => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER | STREAM_CRYPTO_METHOD_TLSv1_3_SERVER,
        "disable_compression" => true,
    ]
]);
```

#### Send message to all connected

[](#send-message-to-all-connected)

```
/**
 * @var \Kim1ne\Socket\Server\Server $server
 */
$server->sendAll('{message: "The message to all"}');
```

#### Send message to selected

[](#send-message-to-selected)

```
use Kim1ne\Socket\Server\Connection;

$server->sendChoice('{message: "The message to selected"}', function (Connection $connection) {
    return (int) $connection->get('user_id') === 1;
});
```

#### Set property for connection

[](#set-property-for-connection)

the object [\\Kim1ne\\Socket\\Server\\Connection](https://github.com/kim1ne/socket-server/blob/main/src/Socket/Server/Connection.php) supports dynamic properties

```
use Kim1ne\Socket\Server\Connection;
use Kim1ne\Socket\Message;
use Kim1ne\Socket\Server\Server;

/**
 * @var \Kim1ne\Socket\Server\Server $server
 */
$server->on('message', function (Message $message, Connection $connection, Server $server) {
    $message = $message->getDecodeJson();

    if ($message['type'] === 'auth') {
        $userId = $message['user_id'];
        $connection->set('user_id', $userId);
    }
})
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance42

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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 ~31 days

Total

2

Last Release

459d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5994f47078df908351e43136f67ea6a8369eeca0945a8d8d500863a36c26b65b?d=identicon)[kim1ne](/maintainers/kim1ne)

---

Top Contributors

[![kim1ne](https://avatars.githubusercontent.com/u/111231185?v=4)](https://github.com/kim1ne "kim1ne (8 commits)")

### Embed Badge

![Health badge](/badges/kim1ne-socket-server/health.svg)

```
[![Health](https://phpackages.com/badges/kim1ne-socket-server/health.svg)](https://phpackages.com/packages/kim1ne-socket-server)
```

PHPackages © 2026

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