PHPackages                             rotoos/think-plugs-workerman - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. rotoos/think-plugs-workerman

ActiveThink-admin-plugin[Utility &amp; Helpers](/categories/utility)

rotoos/think-plugs-workerman
============================

Workerman HttpServer for DeAdmin

v1.1.0(3y ago)017Apache-2.0PHPPHP &gt;=7.1

Since May 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/twin-engine/think-plugs-workerman)[ Packagist](https://packagist.org/packages/rotoos/think-plugs-workerman)[ RSS](/packages/rotoos-think-plugs-workerman/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

ThinkWorkerman
==============

[](#thinkworkerman)

基于 **Workerman** 的 **HttpServer** 插件 ，基于内存方案快速运行 Web 及其他通信协议服务！

### 安装插件

[](#安装插件)

```
### 安装前建议尝试更新所有组件
composer update --optimize-autoloader

composer require rotoos/think-workerman --optimize-autoloader
```

### 卸载插件

[](#卸载插件)

```
composer remove rotoos/think-workerman
```

### 配置参数

[](#配置参数)

配置文件 `config/worker.php`

```
[
    // 服务监听地址
    'host'     => '127.0.0.1',
    // 服务监听端口
    'port'     => 2346,
    // 套接字上下文选项
    'context'  => [],
    // 高级自定义服务类
    'classes'  => '',
    // 消息请求回调处理
    'callable' => null,
    // 服务进程参数配置
    'worker'   => [
        'name'  => 'DeAdmin',
        'count' => 4,
    ],
    // 监控文件变更重载
    'files'    => [
        // 监控检测间隔（单位秒，零不监控）
        'time' => 3,
        // 文件监控目录（默认监控 app 目录）
        'path' => [],
    ],
    // 监控内存超限重载
    'memory'   => [
        // 监控检测间隔（单位秒，零不监控）
        'time'  => 60,
        // 限制内存大小（可选单位有 G M K ）
        'limit' => '1G'
    ],
    // 自定义服务配置（可选）
    'customs'  => [
        // 自定义 text 服务
        'text' => [
            // 进程类型(Workerman|Gateway|Business)
            'type'    => 'workerman',
            // 监听地址(://:)
            'listen'  => 'text://0.0.0.0:8686',
            // 高级自定义服务类
            'classes' => '',
            // 套接字上下文选项
            'context' => [],
            // 服务进程参数配置
            'worker'  => [
                //'name' => 'TextTest',
                // onWorkerStart => [class,method]
                // onWorkerReload => [class,method]
                // onConnect => [class,method]
                // onBufferFull => [class,method]
                // onBufferDrain => [class,method]
                // onError => [class,method]
                // 设置连接的 onMessage 回调
                'onMessage' => function ($connection, $data) {
                    dump($data);
                    $connection->send("hello world");
                }
            ]
        ],
        // 自定义 WebSocket 服务
        'websocket' => [
            // 进程类型(Workerman|Gateway|Business)
            'type'    => 'Gateway',
            // 监听地址(://:)
            'listen'  => 'websocket://0.0.0.0:8688',
            // 高级自定义服务类
            'classes' => '',
            // 套接字上下文选项
            'context' => [],
            // 服务进程参数配置
            'worker'  => [
                //'name' => 'WebsocketTest',
                // onWorkerStart => [class,method]
                // onWorkerReload => [class,method]
                // onConnect => [class,method]
                // onBufferFull => [class,method]
                // onBufferDrain => [class,method]
                // onError => [class,method]
                // 设置连接的 onMessage 回调
                'onMessage' => function ($connection, $data) {
                    //// $connection->worker->connections 为全部连接
                    // foreach($connection->worker->connections as $con)
                    // {
                    //    $con->send($data);
                    // }
                    $connection->send("hello world");
                }
            ]
        ],
    ],
];
```

### 使用方法

[](#使用方法)

在命令行启动服务端

```
#========= 启动参数配置 =========#
### 守护方式运行  -d
### 指定监听域名  --host 127.0.0.1
### 指定监听端口  --port 2346
### 启动指定服务  --custom text

# 启动默认 Http 服务
php think xadmin:worker

# 启动自定义 text 服务，注意 text 为 customs 配置项
php think xadmin:worker --custom text

# 启动自定义 WebSocket 服务，注意 websocket 为 customs 配置项
php think xadmin:worker --custom websocket
```

然后就可以通过浏览器直接访问当前应用

```
http://localhost:2346

```

默认使用 `Workerman` 工作方式，如果需要使用 `Gateway`、`Business` 方式，需要安装 `GatewayWorker` 组件。

安装 `GatewayWorker` 的指令如下：

```
# 安装 GatewayWorker 组件
composer require workerman/gateway-worker
```

Linux 支持操作指令如下：

```
php think xadmin:worker [start|stop|reload|restart|status|-d]

# 以上所有操作效果与 Workerman 官方操作一致，详情请阅读对应文档。
```

Windows 支持操作指令如下：

```
php think xadmin:worker [start|stop|status|-d]

# 以上 stop|status|-d 操作是基于 wimc 实现，Workerman 官方不支持此种方式操作。
```

其他 **workerman** 的参数可以在应用配置目录下的 **worker.php** 里面 **worker** 项配置。

更多其他特性请阅读 **workerman** 文档

### 版权说明

[](#版权说明)

本项目包含的第三方源码和二进制文件之版权信息另行标注。

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Unknown

Total

1

Last Release

1102d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/65806a91f082c630e6d37efd8bc3f0a600e1efaa5a857cd7448f24b426c3cc44?d=identicon)[twin-engine](/maintainers/twin-engine)

### Embed Badge

![Health badge](/badges/rotoos-think-plugs-workerman/health.svg)

```
[![Health](https://phpackages.com/badges/rotoos-think-plugs-workerman/health.svg)](https://phpackages.com/packages/rotoos-think-plugs-workerman)
```

###  Alternatives

[joanhey/adapterman

Use any framework and application with Workerman.

85255.9k1](/packages/joanhey-adapterman)[topthink/think-worker

workerman extend for thinkphp

202227.2k9](/packages/topthink-think-worker)[workerman/crontab

A crontab written in PHP based on workerman

70164.2k58](/packages/workerman-crontab)[workerman/globaldata

8164.2k16](/packages/workerman-globaldata)[workerman/coroutine

Workerman coroutine

15260.0k6](/packages/workerman-coroutine)

PHPackages © 2026

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