swoole /swoole-src
🚀 Coroutine-based concurrency library for PHP
★ 18,937⑂ 3,151👁 793⑃ 2,503● 3,773▤ 273
+0
日增长
18,937
stars
3,151
forks
793
watchers
2,503
prs
3,773
issues
273
releases
README
Swoole An event-driven networking engine and coroutine runtime for PHP Swoole is a PHP extension for building persistent network services and concurrent I/O applications. Its C/C++ core provides an event loop, coroutine scheduler, servers, clients, and protocol implementations. The bundled PHP library adds connection pools, proxies, and higher-level utilities. Use Swoole for HTTP APIs, WebSocket applications, TCP/UDP gateways, and services that need to handle many connections without a separate PHP process for every request. Version note: master is the development branch for Swoole 6.3 and currently supports PHP 8.2–8.5. For production, choose a released version and check the supported versions for its PHP compatibility and maintenance status. At a glance | Capability | Main APIs | Typical use | | --- | --- | --- | | Event-driven servers | Swoole\Server, Swoole\Event | TCP, UDP, Unix sockets, connection events | | Coroutines | Swoole\Coroutine, Channel, Socket | Concurrent I/O and task coordination | | HTTP and WebSocket | Swoole\Http\Server, Swoole\WebSocket\Server | APIs, streaming responses, real-time messaging | | Coroutine clients | Swoole\Coroutine\Client, Swoole\Coroutine\Http\Client | Calls to TCP and HTTP upstream services | | Runtime hooks | Swoole\Runtime | Coroutine-aware behavior for supported PHP functions | | Processes and shared data | Swoole\Process, Swoole\Table, atomics | Background work and interprocess state | | Timers and system I/O | Swoole\Timer, Swoole\Coroutine\System | Scheduled work, file and process operations | How Swoole works The Reactor watches sockets and other registered file descriptors, then dispatches events to callbacks. Servers can run multiple worker processes to use multiple CPU cores. Within a worker, coroutines let other tasks run while one task waits for supported I/O. Task workers provide a separate execution path for jobs that should not hold up request handling. Coroutines are a concurrency tool, not automatic CPU parallelism. A CPU-intensive PHP loop still occupies its worker until it yields or finishes. Use worker or task processes, or optional thread support, when work needs parallel execution. Swoole workers are long-lived. Global variables, static state, and open resources can survive beyond one request. Close or recycle connections, enforce timeouts, and keep per-request data out of process-wide state. Ordinary PHP variables are not shared between worker processes; use IPC, Table, or external storage when data must be shared. Functional modules Servers and network protocols Swoole\Server handles TCP, UDP, and Unix socket services. It supports multiple listening ports, worker and task worker processes, connection management, heartbeats, and configurable packet boundaries such as length fields or EOF markers. Swoole\Event lets an application register its own file descriptors with the event loop, while Swoole\Timer schedules one-off or recurring callbacks. Choose the
Top issues
#6139SIGTERM 平滑退出时过早移除 worker pipe 读事件,导致已提交 Task 的 onFinish 丢失5 comments · 2026-08-04#6409HTTP/2 server does not send WINDOW_UPDATE, so responses larger than 64 KiB are reset by the peer2 comments · 2026-11-13#6390taskWaitMulti() segfaults with string-keyed task array when enable_coroutine is false (regression since 6.1.0)2 comments · 2026-11-11#6414macos 下 PHP 8.4.12 协程中使用异或出现段错误1 comments · 2026-11-15
Discussions
#6207Preferred workflow for remaining bug fixes3 comments · 2026-09-08#5979High load when many persistent Redis clients reconnect simultaneously to Swoole\Redis\Server0 comments · 2026-01-18#5954wnmp One-click installation of Swoole 6.1.4 is now supported in PHP 8.5.1 comments · 2025-12-13#5874coroutine questions1 comments · 2025-10-05#5872Where to init DB Pool?1 comments · 2025-10-02#5870For Pooling, which is best Channel Or splQueue ?0 comments · 2025-09-30#5831xdebug - what is a trick to get breakpoints working after coroutine?0 comments · 2025-07-26#5806Is there any way to limit execution time of a request?1 comments · 2025-06-25
Latest release
v6.2.5 v6.2.5 2026-11-07- Fix the release of suspended cURL handles after the request is closed. - Fix the cleanup of the CURLOPT_PRIVATE option in curl_reset(). - Fix the inheritance of blocked signals by PHP worker threads and server worker threads. - Fix the restoration of signal actions before the listener is removed. - Fix the resume lifecycle of queued cURL requests. - Fix the test client's acceptance of platform-specific connection failures. - Fix the scheduling issue of process pool synchronous worker threads. - Fix the reset of signal listener state in forked child processes. - Fix the client's check