About this project

Swoole is a PHP extension providing an event-driven, asynchronous, coroutine-based concurrency runtime. It is written as a C extension and installed via PECL or compiled from source; it requires Linux, macOS, Cygwin or WSL, PHP 8.2 or later, and GCC 4.8 or later. Core capabilities described in the README: - Coroutines: built-in coroutine scheduling lets developers write synchronous-looking PHP code that executes asynchronously. Coroutines are described as ultra-lightweight threads, with thousands creatable in a single process. - Runtime hooks: Swoole\Runtime::enableCoroutine() replaces Zend VM stream function pointers so that blocking I/O functions become non-blocking and coroutine-scheduled. Supported integrations include ext-curl (with Symfony and Guzzle), ext-redis, ext-mysqli, several PDO drivers (MySQL, PostgreSQL, SQLite, Oracle, ODBC), stream functions over TCP/UDP/UDG/Unix/SSL-TLS and filesystem APIs, ext-sockets, ext-soap, sleep functions, proc_open, gethostbyname, shell_exec, exec, and file functions such as fread/fopen/fsockopen/fwrite/flock. - Servers: HTTP, WebSocket, HTTP/2 and TCP servers can share one event loop; a WebSocket server example also listens for raw TCP on a second port. The network layer uses epoll/kqueue. - Clients: coroutine clients for HTTP, WebSocket, HTTP/2 and TCP are shown, with DNS, request and response handling scheduled automatically. - Channels: Swoole\Coroutine\Channel provides CSP-style communication between coroutines, demonstrated with a Redis connection pool and a producer/consumer example. - Timers: Swoole\Timer::tick, after, clear and exists, plus coroutine-based sleeping loops. - Mixed workloads: the README illustrates 10K sleeps, file reads/writes, PDO/MySQLi queries, and TCP/UDP server-client exchanges within a single process using runtime hooks. Installation options are PECL (pecl install swoole) or source build (phpize, configure, make, make install), with optional flags such as --enable-openssl, --enable-sockets, --enable-mysqlnd and --enable-swoole-curl. Async clients and APIs were moved to a separate swoole_async extension starting with version 4.3.0. The project is licensed under Apache 2.0 and points to wiki.swoole.com for documentation, an IDE helper repository, an Awesome Swoole list, and community channels on Twitter, Discord and a Chinese-language community.