swoole /swoole-src

🚀 Coroutine-based concurrency library for PHP

★ 18,937⑂ 3,151👁 793⑃ 2,503● 3,773▤ 273
C++Apache-2.0Created 2012-07-21www.swoole.com
Download: v6.2.5v6.2.5 ↓6.2.52026-11-07
+0
Daily
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

Discussions

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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON