PHPackages                             easyswoole/socket - 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. [Framework](/categories/framework)
4. /
5. easyswoole/socket

ActiveLibrary[Framework](/categories/framework)

easyswoole/socket
=================

An efficient swoole framework

1.3.1(3y ago)2132.2k↓23.5%49Apache-2.0PHPPHP &gt;=7.1.0

Since Aug 10Pushed 3y agoCompare

[ Source](https://github.com/easy-swoole/socket)[ Packagist](https://packagist.org/packages/easyswoole/socket)[ Docs](https://www.easyswoole.com/)[ RSS](/packages/easyswoole-socket/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (29)Used By (9)

socket
======

[](#socket)

```
use EasySwoole\Socket\AbstractInterface\Controller;
use EasySwoole\Socket\AbstractInterface\ParserInterface;
use EasySwoole\Socket\Bean\Response;
use EasySwoole\Socket\Bean\Caller;

class C extends Controller{

    private $hit = 0;
    protected $hitTime = 0;

    function __construct()
    {
        var_dump('controller create  '.spl_object_hash($this));
        parent::__construct();
    }

    protected function onRequest(?string $actionName): bool
    {

        $this->hit++;
        $this->hitTime = time();
        return true;
    }

    function test()
    {
        var_dump($this->hit,$this->hitTime);
//        co::sleep(10);
        $this->response()->setMessage('time:'.time());
    }

    protected function gc()
    {
        parent::gc(); // TODO: Change the autogenerated stub
        var_dump('controller has ben gc');
    }
}

class Parser implements ParserInterface{

    public function decode($raw, $client): ?Caller
    {
        // TODO: Implement decode() method.
        $ret =  new Caller();
        $ret->setControllerClass(C::class);
        $ret->setAction('test');
        return $ret;
    }

    /*
     * 如果这里返回null，则不给客户端任何数据
     */
    public function encode(Response $response, $client): ?string
    {
        // TODO: Implement encode() method.
        return $response->__toString();
    }

}

$server = new \Swoole\Server("127.0.0.1", 9501);
$server->set([
    'worker_num'=>1
]);

$conf = new \EasySwoole\Socket\Config();
$conf->setType($conf::TCP);
$conf->setParser(new Parser());
$conf->setOnExceptionHandler(function (\swoole_server $server,\Throwable $throwable,string $raw,$client,Response $response){
    $response->setStatus('error');
    $response->setStatus($response::STATUS_RESPONSE_AND_CLOSE);
});

$dispatch = new \EasySwoole\Socket\Dispatcher($conf);
$server->on('receive', function ($server, $fd, $reactor_id, $data)use($dispatch) {
    $dispatch->dispatch($server,$data,$fd,$reactor_id);
});
$server->on('close', function ($server, $fd) {
    echo "connection close: {$fd}\n";
});
$server->start();
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 90.6% 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 ~61 days

Recently: every ~228 days

Total

28

Last Release

1169d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/45c234d5f129ea570e630425636299127647534f0c2cbb073555e2c45d403d6f?d=identicon)[kiss291323003](/maintainers/kiss291323003)

---

Top Contributors

[![kiss291323003](https://avatars.githubusercontent.com/u/24490609?v=4)](https://github.com/kiss291323003 "kiss291323003 (29 commits)")[![Player626](https://avatars.githubusercontent.com/u/44792981?v=4)](https://github.com/Player626 "Player626 (2 commits)")[![tioncico](https://avatars.githubusercontent.com/u/31308307?v=4)](https://github.com/tioncico "tioncico (1 commits)")

---

Tags

asyncframeworkswooleeasyswoole

### Embed Badge

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

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

###  Alternatives

[easyswoole/easyswoole

An efficient swoole framework

4.8k186.9k50](/packages/easyswoole-easyswoole)[easyswoole/mysqli

An efficient swoole framework

34120.5k27](/packages/easyswoole-mysqli)[easyswoole/redis

easyswoole component

3391.8k12](/packages/easyswoole-redis)[easyswoole/kafka

An efficient swoole framework

4211.1k](/packages/easyswoole-kafka)[easyswoole/compiler

easyswoole component

691.1k](/packages/easyswoole-compiler)[easyswoole/fast-cache

An efficient swoole framework

1030.3k2](/packages/easyswoole-fast-cache)

PHPackages © 2026

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