Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
W

workerman

> 数据库
Open source

An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.

11.5K stars0 likes1 views
WebsiteGitHub

About

An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.

Workerman

What is it

Workerman is an asynchronous event-driven PHP framework with high performance to build fast and scalable network applications. It supports HTTP, WebSocket, custom protocols, coroutines, and connection pools, making it ideal for handling high-concurrency scenarios efficiently.

Requires

A POSIX compatible operating system (Linux, OSX, BSD)
POSIX and PCNTL extensions required
Event/Swoole/Swow extension recommended for better performance

Installation

composer require workerman/workerman

Documentation

https://manual.workerman.net

Basic Usage

A websocket server

php
<?php

use Workerman\Worker;

require_once __DIR__ . '/vendor/autoload.php';

// Create a Websocket server
$ws_worker = new Worker('websocket://0.0.0.0:2346');

// Emitted when new connection come
$ws_worker->onConnect = function ($connection) {
    echo "New connection\n";
};

// Emitted when data received
$ws_worker->onMessage = function ($connection, $data) {
    // Send hello $data
    $connection->send('Hello ' . $data);
};

// Emitted when connection closed
$ws_worker->onClose = function ($connection) {
    echo "Connection closed\n";
};

// Run worker
Worker::runAll();

An http server

php
use Workerman\Worker;

require_once __DIR__ . '/vendor/autoload.php';

// #### http worker ####
$http_worker = new Worker('http://0.0.0.0:2345');

// 4 processes
$http_worker->count = 4;

// Emitted when data received
$http_worker->onMessage = function ($connection, $request) {
    //$request->get();
    //$request->post();
    //$request->header();
    //$request->cookie();
    //$request->session();
    //$request->uri();
    //$request->path();
    //$request->method();

    // Send data to client
    $connection->send("Hello World");
};

// Run all workers
Worker::runAll();

A tcp server

…

Enable SSL

…

AsyncTcpConnection (tcp/ws/text/frame etc...)

…

Coroutine

Coroutine is used to create coroutines, enabling the execution of asynchronous tasks to improve concurrency performance.

php
<?php
use Workerman\Connection\TcpConnection;
use Workerman\Coroutine;
use Workerman\Events\Swoole;
use Workerman\Protocols\Http\Request;
use Workerman\Worker;
require_once __DIR__ . '/vendor/autoload.php';

$worker = new Worker('http://0.0.0.0:8001');

$worker->eventLoop = Swoole::class; // Or Swow::class or Fiber::class

$worker->onMessage = function (TcpConnection $connection, Request $request) {
    Coroutine::create(function () {
        echo file_get_contents("http://www.example.com/event/notify");
    });
    $connection->send('ok');
};

Worker::runAll();

Note: Coroutine require Swoole extension or Swow extension or Fiber revolt/event-loop, and the same applies below

Barrier

Barrier is used to manage concurrency and synchronization in coroutines. It allows tasks to run concurrently and waits until all tasks are completed, ensuring process synchronization.

…

Parallel

Parallel executes multiple tasks concurrently and collects results. Use add to add tasks and wait to wait for completion and get results. Unlike Barrier, Parallel directly returns the results of each task.

…

Channel

Channel is a mechanism for communication between coroutines. One coroutine can push data into the channel, while another can pop data from it, enabling synchronization and data sharing between coroutines.

…

Pool

Pool is used to manage connection or resource pools, improving performance by reusing resources (e.g., database connections). It supports acquiring, returning, creating, and destroying resources.

…

Pool for automatic acquisition and release

…

Available commands

php start.php start
php start.php start -d
php start.php status
php start.php status -d
php start.php connections
php start.php stop
php start.php stop -g
php start.php restart
php start.php reload
php start.php reload -g

Benchmarks

https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=plaintext&l=zik073-1r

Supported by

Other links with workerman

webman
AdapterMan

Donate

PayPal

LICENSE

Workerman is released under the MIT license.

Issues· 109 open

View all issuesOpen on GitHub
  • #1163

    We need to investigate the new poll_api from PHP/8.6

    Updated Aug 26, 2026
  • #1161

    Swoole6.2.1 事件循环下 HTTPS 请求超时:stream_socket_enable_crypto() 返回 false

    Updated Aug 23, 2026
  • #1106

    [BUG] eventLoop设为Swoole,当Swoole版本为6.x在非iouring下响应大文件异常的BUG

    bugUpdated Jul 15, 2026
  • #1099

    Add new event engine io_uring [sugestion]

    Updated Jun 11, 2026
  • #1136

    [Feature request?] Add Support Transfer-Encoding chunked in Request

    enhancementUpdated Apr 3, 2026
  • #1142

    HTTP 1.1 use by default persistent connections

    Updated Apr 1, 2026
  • #691

    Low performance if using Nginx as a reverse proxy

    Updated Jan 11, 2026
  • #1076

    websocket的onMessage方法中是否有办法知道客户端发送的消息是text类型还是binary类型?

    Updated Aug 28, 2025
  • #1120

    [Feature request?] Support Transfer-Encoding chunked with no Content-Length

    Updated Aug 25, 2025
  • #1114

    [feature request?] Worker count scale

    Updated Jul 25, 2025

> Tags

PHPasynchronousevent-drivenhigh-performancephp

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库