PHPackages                             chenyongze/swoole-common - 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. chenyongze/swoole-common

ActiveLibrary

chenyongze/swoole-common
========================

swoole server yongze.chen websocket

0272PHP

Since Nov 2Pushed 8y ago1 watchersCompare

[ Source](https://github.com/chenyongze/swoole-common)[ Packagist](https://packagist.org/packages/chenyongze/swoole-common)[ RSS](/packages/chenyongze-swoole-common/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

swoole-common
=============

[](#swoole-common)

> composer install

> composer require chenyongze/swoole-common:master-dev

> run webSocket server #php examples/websocket-server.php

> browser open

Socket.html

```
>

    Title

    var msg = document.getElementById("msg");
    var wsServer = 'ws://127.0.0.1:9505';
    //调用websocket对象建立连接：
    //参数：ws/wss(加密)：//ip:port （字符串）
    var websocket = new WebSocket(wsServer);
    console.log(websocket);
    //onopen监听连接打开
    websocket.onopen = function (evt) {
        //websocket.readyState 属性：
        /*
         CONNECTING    0    The connection is not yet open.
         OPEN    1    The connection is open and ready to communicate.
         CLOSING    2    The connection is in the process of closing.
         CLOSED    3    The connection is closed or couldn't be opened.
         */
        msg.innerHTML = websocket.readyState;
    };

    function song(){
        var text = document.getElementById('text').value;
        document.getElementById('text').value = '';
        //向服务器发送数据
        websocket.send(text);
    }
    //监听连接关闭
    //    websocket.onclose = function (evt) {
    //        console.log("Disconnected");
    //    };

    //onmessage 监听服务器数据推送
    websocket.onmessage = function (evt) {
        msg.innerHTML += evt.data +'';
//        console.log('Retrieved data from server: ' + evt.data);
    };
    //监听连接错误信息
    //    websocket.onerror = function (evt, e) {
    //        console.log('Error occured: ' + evt.data);
    //    };

```

> server push message

```
require __DIR__.'/../vendor/autoload.php';
$client = new \Yongze\swoole\WebSocketClient('127.0.0.1', 9505);

$message = 'good job!';
if (!$client->connect())
{
    echo "connect failed \n";
    return false;
}
if (!$client->send($message))
{
    echo $message. " send failed \n";
    return false;
}
echo "send succ \n";
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![chenyongze](https://avatars.githubusercontent.com/u/4531363?v=4)](https://github.com/chenyongze "chenyongze (13 commits)")

### Embed Badge

![Health badge](/badges/chenyongze-swoole-common/health.svg)

```
[![Health](https://phpackages.com/badges/chenyongze-swoole-common/health.svg)](https://phpackages.com/packages/chenyongze-swoole-common)
```

PHPackages © 2026

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