Scripts2026年5月19日·1 分钟阅读

Workerman — High-Performance Async PHP Socket Framework

Workerman is a pure PHP asynchronous event-driven socket framework for building TCP, UDP, HTTP, and WebSocket servers without any C extensions.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Workerman Overview
通用 CLI 安装命令
npx tokrepo install c09ce3ad-53c0-11f1-9bc6-00163e2b0d79

Introduction

Workerman enables PHP developers to build long-running network services using pure PHP, no C extensions required. It supports millions of concurrent connections and is commonly used for real-time chat, push notifications, and IoT gateways.

What Workerman Does

  • Runs persistent PHP processes for high-performance network services
  • Supports TCP, UDP, HTTP, and WebSocket protocols natively
  • Handles high concurrency through event-driven non-blocking I/O
  • Provides timer, signal handling, and process management APIs
  • Works as a foundation for real-time applications and microservices

Architecture Overview

Workerman uses a multi-process model with a master process that forks worker processes. Each worker runs an event loop (using libevent, event, or a built-in select fallback) that handles socket I/O without blocking. Connections are distributed across workers by the OS kernel, and each worker can handle thousands of simultaneous connections.

Self-Hosting & Configuration

  • Install via Composer with composer require workerman/workerman
  • Start workers with php start.php start (use -d for daemon mode)
  • Configure worker count with $worker->count = 4
  • Set transport to SSL/TLS for encrypted connections
  • Monitor processes with php start.php status

Key Features

  • Zero C extension dependencies for basic usage
  • Multi-process architecture with graceful reload
  • Built-in HTTP and WebSocket server implementations
  • Custom protocol support via simple interfaces
  • Compatible with standard PHP libraries and Composer packages

Comparison with Similar Tools

  • Swoole — C extension with coroutines; Workerman is pure PHP with event-driven callbacks
  • ReactPHP — similar event-loop model; Workerman adds multi-process management built in
  • Node.js — JavaScript event-driven runtime; Workerman offers the same model for PHP teams
  • RoadRunner — Go-based process manager; Workerman stays fully within the PHP ecosystem
  • Amphp — async PHP library; Workerman focuses on network server use cases specifically

FAQ

Q: Does Workerman require the Swoole extension? A: No. Workerman is pure PHP. It optionally uses the event or libevent extensions for better performance.

Q: Can Workerman run alongside PHP-FPM? A: Yes. Workerman runs as a separate process and can coexist with PHP-FPM on the same server.

Q: How many connections can Workerman handle? A: Workerman has been benchmarked handling over one million concurrent connections on a single server with appropriate OS tuning.

Q: Is Workerman suitable for production use? A: Yes. It is widely used in production for chat systems, game servers, and IoT platforms, particularly in the Chinese PHP ecosystem.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产