A high-performance, event-driven, coroutine-based concurrency library for PHP that enables asynchronous programming.
Swoole is a C-extension for PHP that provides an event-driven, coroutine-based concurrency framework. It fundamentally changes PHP's execution model by enabling asynchronous, non-blocking I/O operations, allowing developers to build high-performance network applications like microservices, real-time APIs, and game servers that can handle massive numbers of concurrent connections.
PHP developers and teams building high-throughput, low-latency network services, real-time applications (like chat or gaming backends), microservices, or anyone needing to overcome the traditional blocking I/O limitations of standard PHP.
Developers choose Swoole because it allows them to write clean, synchronous-looking PHP code that performs like asynchronous Node.js or Go applications. It offers exceptional performance (often ranking top in web framework benchmarks) without requiring a complete shift to a new language or complex async/await patterns.
🚀 Coroutine-based concurrency library for PHP
Coroutines allow writing asynchronous code in a familiar synchronous manner, as shown in the HTTP service example where `file_get_contents` is used without callbacks for concurrent requests.
Runtime hooks transform standard blocking PHP functions like PDO, Redis, and `sleep` into non-blocking operations with `Swoole\Runtime::enableCoroutine()`, enabling massive concurrency as demonstrated in benchmark scripts.
Provides coroutine-enabled servers for HTTP/1.1, HTTP/2, WebSocket, and TCP/UDP, allowing mixed services on a single event loop, illustrated in the mixed server code snippet.
Implements CSP with channels for safe inter-coroutine communication, ideal for connection pools and producer-consumer patterns, as shown in the Redis pool implementation handling 1000 concurrent requests.
Requires compiling and installing a C extension via PECL or source, adding deployment complexity compared to pure PHP libraries, as detailed in the installation section with steps for configuration and make.
Not all PHP libraries are designed for coroutine environments; the README lists supported extensions, but unsupported ones may cause blocking or require workarounds, limiting drop-in use with existing code.
Major updates can introduce breaking changes, such as moving async clients to a separate extension in v4.3.0, requiring additional installation steps and potential code adjustments.
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.
Event-driven, non-blocking I/O with PHP.
Asynchronous WebSocket server
A non-blocking concurrency framework for PHP applications. 🐘
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.