osenv/swoole-src
37.5
Weak · 5 August 2026
8.6k
lines of production code
PHP
primary language
5
measurements over time
What this system is
This system is a high-performance, asynchronous, coroutine-based networking and concurrency framework for PHP, known as Swoole. It provides a comprehensive suite of tools for building scalable network applications, featuring support for HTTP/1, HTTP/2, WebSocket, TCP, UDP, and Unix sockets. The framework includes built-in clients and servers for databases like MySQL, PostgreSQL, and Redis, alongside utilities for process management, memory mapping, and atomic operations. Additionally, it offers extensive benchmarking scripts and a robust test suite to ensure stability across various protocols and runtime environments.
How it got here
2012–2014 — Core C extension architecture
21 changes.
This period focused on building the foundational C/C++ infrastructure for the Swoole framework, introducing core modules for networking, memory management, and process/thread factories. The work established the internal API and data structures necessary to support high-concurrency server and client operations.
2015–2016 — comprehensive example and benchmark expansion
20 changes.
This period focused on extensively expanding the project's example suite, introducing new scripts for networking protocols, database interactions, and concurrency patterns. The work also included adding benchmarking tools and utility scripts to support testing and performance evaluation.
2017 — Test coverage expansion and HTTP/2 support
23 changes.
This period focused on establishing a comprehensive automated testing infrastructure for the Swoole project, introducing unit tests for nearly all core components including HTTP/2, coroutines, and async I/O. The work also added example scripts and SSL certificates to demonstrate new HTTP/2 client and server capabilities.
2018 — Coroutine integration and testing
7 changes.
This period focused on expanding the coroutine subsystem by adding comprehensive examples and test coverage for Redis, PostgreSQL, and socket communications. The work emphasized validating the behavior of the new coroutine APIs, including handling edge cases, connection states, and asynchronous workflows across various protocols.
Features
Add HTTP/2 client and server examples
New example scripts are provided to demonstrate HTTP/2 usage: a client example (examples/http2/client.php) that connects to a host using SSL, and a server example (examples/http2/server.php) that listens on port 9501 with SSL enabled and the HTTP/2 protocol.
examples/http2 · high confidence
Add IPv6 TCP and UDP server and client examples
Added four new example scripts in the examples/ipv6 directory: tcp\_server.php, tcp\_client.php, udp\_server.php, and udp\_client.php. These files demonstrate how to create and interact with IPv6-enabled TCP and UDP servers and clients using the Swoole library, specifically utilizing the SWOOLE\_SOCK\_TCP6 and SWOOLE\_SOCK\_UDP6 socket types.
examples/ipv6 · high confidence
Add MySQL example scripts for prepared statements, transactions, and async operations
The examples/mysql directory now includes new PHP scripts demonstrating MySQL usage patterns. These include prepared statement examples for both the MySQLi and PDO extensions (mysqli\_prepare.php, pdo\_prepare.php, pdo\_prepare2.php, prepare.php), a script for handling database transactions using the Swoole MySQL client (transaction.php), and examples for asynchronous MySQL operations (real\_async.php) and synchronous/escape string usage (sync.php).
examples/mysql · high confidence
Add PHP network and debugging examples
Added new PHP example scripts demonstrating various networking and debugging capabilities: a debug server for tracking memory allocations and invalid frees, an inotify-based file watcher, MySQLi async query handling, and multiple socket/stream clients and servers (TCP, UDP, and stream-based) for testing network connectivity and server behavior.
examples/php · high confidence
Add PostgreSQL coroutine example with metadata support
A new example file, postgresql\_coro.php, has been added to the examples/postgresql directory. It demonstrates how to use the Swoole coroutine PostgreSQL client to connect to a database, execute a query, and retrieve metadata about a table using the new metaData method.
examples/postgresql · high confidence
Add Redis client, server, and subscription examples
Added example scripts demonstrating the new Swoole Redis capabilities: a basic client interaction (client.php), a Predis-style wrapper (predis.php), a Redis-compatible server implementation (server.php) supporting GET, SET, SADD, hSET, and other commands, and a message subscription example (subscribe.php) showing pub/sub functionality.
examples/redis · high confidence
Add Redis coroutine examples
Added two new PHP examples for Redis coroutine usage: eval.php demonstrates the eval command, and request.php demonstrates the request method, both utilizing the Co\\Redis class within a coroutine context.
examples/coroutine/redis · high confidence
Add SSL/TLS example files for Swoole clients and servers
Added a new set of example files in the examples/ssl directory to demonstrate SSL/TLS support for Swoole. This includes PHP and C-based client and server implementations, along with corresponding SSL certificate and key files. The examples cover various use cases such as async clients, HTTP clients, WebSocket servers, and stream-based clients, all configured with SSL/TLS encryption.
examples/ssl · high confidence
Add WebSocket client and server examples
Added new example files for WebSocket communication, including a PHP-based WebSocket client (WebSocketClient.php) and server (server.php), along with async client and HTML/PHP client examples. The client implementation includes constants for WebSocket opcodes and close codes, handles the HTTP upgrade handshake, and provides methods for sending and receiving data. The server example demonstrates handling handshake, open, message, and close events, as well as task processing.
examples/udp, examples/websocket · high confidence
Add client example scripts for various connection modes
Added new example scripts in the examples/client directory to demonstrate different client connection modes: async TCP (async.php), sync TCP (sync.php), long TCP connections (long\_tcp.php), UDP sync/async (udp\_sync.php, udp\_async.php), socket retrieval (get\_socket.php), and multi-client select-based communication (select.php), along with a test file (test.txt).
examples/client · high confidence
Add coroutine channel select examples
Added four new PHP example files (1.php, 2.php, 3.php, 4.php) in the examples/coroutine/select directory. These files demonstrate the usage of the chan::select function for handling multiple channels, including scenarios with read-only channels, write-only channels, and timeout configurations.
examples/coroutine/select · high confidence
Add coroutine-based socket communication examples
Added new example scripts for the socket\_coro feature, demonstrating how to use the Co\\Socket class for asynchronous client and server communication. The client script connects to a server, sends and receives data in a loop, and handles the connection lifecycle. The server script listens for incoming connections and spawns a new coroutine for each client to handle data exchange. These examples illustrate the usage of the new coroutine socket API.
_examples/socket\coro · high confidence
Add length-based protocol examples for Swoole
Added PHP examples demonstrating length-based packet parsing in Swoole. The server-side (server.php, func.php) configures the server to parse packets based on a length header, with func.php introducing a custom length calculation function. The client-side (client.php, async\_client.php) demonstrates sending and receiving data using the same length-prefix protocol, supporting both synchronous and asynchronous communication patterns.
examples/length · high confidence
Add multicast communication examples
Added new example scripts for UDP multicast communication. The server (examples/multicast/server.php) demonstrates joining a multicast group and handling incoming packets, while the client (examples/multicast/client.php) shows how to send and receive UDP data. Additionally, a new locking example (examples/lock/lock.php) was added to demonstrate process synchronization using mutexes.
examples/multicast · high confidence
Add namespace-based Swoole examples
Added new example files demonstrating the use of Swoole's namespace-style API, including HTTP server, TCP server, timer, and atomic operation samples, along with a README explaining how to enable namespace support in php.ini.
examples/namespace · high confidence
Added EOF protocol example for Swoole client and server
Added example files (async\_client.php, client.php, server.php) demonstrating the use of the EOF (End of File) protocol in Swoole. The server configures 'open\_eof\_check' and 'open\_eof\_split' to handle message boundaries using a specific EOF delimiter. The client examples show how to send and receive data using both synchronous and asynchronous Swoole clients with EOF-based packet parsing.
examples/eof · high confidence
Added SSL certificate, CSR, and private key for the ssl\_passwd example
The ssl\_passwd example now includes the necessary SSL files (ssl.crt, ssl.csr, and ssl.key) to demonstrate SSL/TLS configuration. These files provide the certificate, certificate signing request, and encrypted private key required for the example to function.
_examples/ssl/ssl\passwd · high confidence
Added Travis CI compilation script
A new shell script, compile.sh, has been added to the travis directory. This script automates the PHP extension compilation process by running phpize, configuring the build, and executing make to compile the extension.
travis · high confidence
Added Unix socket example scripts
Added new example scripts for Unix socket communication, including asynchronous and synchronous clients, as well as stream and datagram server implementations. These files demonstrate how to use Unix domain sockets with the Swoole library, covering both stream and datagram protocols.
examples/unixsock · high confidence
Added comprehensive benchmark scripts for Swoole and other runtimes
The benchmark directory now includes a wide range of new test scripts to evaluate performance across different protocols and languages. PHP-based benchmarks cover HTTP, TCP, UDP, WebSocket, coroutine, and timer operations, alongside a table memory benchmark. Additional scripts test async WebSocket clients, serialization, and EOF/length-based TCP servers. The suite also includes Go implementations for HTTP, HTTP2 (using fasthttp), Redis, and TCP echo servers, as well as JavaScript and Go HTTP/TCP clients. These additions provide standardized tools for measuring throughput, latency, and resource usage in the benchmark environment.
benchmark · high confidence
Added core data structures and utilities
The core library now includes new implementations for several data structures and utility functions. This adds a thread-safe ring queue, a channel for inter-process communication, a dynamic array, a red-black tree, a min/max heap, a linked list, a hash map, and string utilities. These components provide the foundational building blocks for the rest of the framework.
src/core · high confidence
Added kqueue IDE helper for Linux
A new header file, include/helper/kqueue.h, has been added to provide IDE support for kqueue-related functions and structures on Linux. This includes definitions for the kevent struct, event filters (EVFILT\_READ, EVFILT\_WRITE), event flags (EV\_ADD, EV\_DELETE, EV\_CLEAR), and stubs for kevent, kqueue, and EV\_SET, facilitating better code completion and navigation in IDEs.
include/helper · medium confidence
Added leader-follower channel example
A new example script, examples/channel/leader\_follower.php, was added to demonstrate a leader-follower pattern using Swoole processes and channels. The script creates four worker processes that continuously pop data from a shared channel, while a timer pushes messages into the channel every two seconds.
examples/channel · high confidence
Added new PHP utility scripts in the tools directory
Four new PHP scripts have been added to the tools directory: check-package.php, which scans the tests directory and outputs XML for unit test files; export.php, which uses ReflectionClass to export a specified class; gen-data.php, which generates a text file with specific repeated character patterns; and ip.php, which resolves an IP address to a location using a free API. These scripts provide new capabilities for package validation, class inspection, test discovery, data generation, and IP geolocation.
tools · high confidence
Added new example scripts for Swoole features
The examples directory now includes a variety of new example scripts demonstrating Swoole capabilities. These include buffer management (buffer.php, test\_buffer.php), client-server interactions (client2.php, recv\_1m\_client.php, recv\_file.php, send\_1m\_svr.php), connection handling (c10k.php), channel-based communication (channel.php), database connection pooling (db\_pool.php, redis\_pool.php), proxying (proxy\_sync.php, mysql\_proxy\_server.php), file transfer (recv\_file.php, sendfile\_server.php), serialization (serialize.php, serialize2.php), and utility functions (get\_local\_ip.php, version.php). Additionally, C/C++ examples (server.c, test\_server.c) and PHP examples for hot updates (server\_hot\_update\_opcache.php), CPU affinity (set\_cpu\_affinity.php), HTTP clients (swoole\_http\_client.php), and weather services (weather\_server.php) have been added to the examples directory.
examples · high confidence
Added third-party HTTP and multipart parsers
The project now bundles several third-party libraries as submodules or source files to handle HTTP and multipart data. This includes the hiredis and nghttp2 libraries, the jemalloc memory allocator, and C-based parsers for HTTP headers (php\_http\_parser, picohttpparser) and multipart/form-data (multipart\_parser). These additions provide the underlying parsing logic for incoming requests and uploads.
thirdparty · high confidence
Added timer examples for after, clear, and tick functions
New example files (after.php, clear.php, tick.php) were added to the examples/timer directory, demonstrating the usage of the swoole\_timer\_after, swoole\_timer\_clear, and swoole\_timer\_tick functions. These examples illustrate how to set one-off and recurring timers, as well as how to clear them.
examples/timer · high confidence
Adds new tasking examples for Swoole server
The examples/task directory now includes several new PHP scripts demonstrating Swoole server tasking capabilities. These include http.php, msg\_push.php, shared\_client.php, shared\_server.php, task.php, task\_coro.php, task\_num.php, task\_queue.php, and task\_stream.php. These files provide practical examples of how to use the tasking features of the Swoole server, including both synchronous and asynchronous task handling, task queues, and coroutine-based tasking.
examples/task · high confidence
Expanded coroutine examples for HTTP, MySQL, Redis, and UDP
Added a suite of new example scripts in the coroutine directory to demonstrate coroutine-based networking and database interactions. This includes HTTP server and client implementations (including HTTP/2 and multi-client scenarios), MySQL connection and prepared statement examples, Redis connection pooling and subscription demos, and UDP/TCP timeout handling. The collection also adds examples for channel selection, file I/O (fread/fwrite/fgets), sleep, stack depth configuration, and WebSocket communication, providing comprehensive usage patterns for the coroutine runtime.
examples/coroutine · high confidence
Expanded process management examples in Swoole
The examples/process directory has been significantly expanded with new demonstration scripts for process management, including alarm handling (alarm.php), asynchronous master-worker communication (async\_master.php), message queues (msgqueue.php, msgqueue2.php, msgqueue\_client.php), process pools (pool.php, pool\_socket.php), and function timeouts (func\_timeout.php). These additions provide practical examples for using Swoole's process APIs, such as IPC\_NOWAIT, useQueue, and alarm mechanisms.
examples/process · high confidence
Introduce new network module components for client, connection, and process management
The src/network directory now includes newly added C source files—Client.c, Connection.c, DNS.c, Manager.c, Port.c, and ProcessPool.c—that implement core networking capabilities. These additions provide the underlying infrastructure for TCP/UDP/Unix socket clients, connection state management, asynchronous DNS resolution, process pool management, and port configuration, forming the foundation for the Swoole server and client APIs.
src/network · high confidence
Introduce new pipe backend implementations
Added three new pipe backend implementations in the \src/pipe\ directory: \PipeBase.c\ for standard POSIX pipes, \PipeEventfd.c\ for eventfd-based communication, and \PipeUnsock.c\ for Unix socket pair communication. These files provide the underlying mechanisms for inter-process communication within the Swoole runtime.
src/pipe · high confidence
New HTTP client and server examples
Added a suite of new example scripts in the \examples/http\ directory to demonstrate HTTP client and server capabilities. This includes asynchronous and synchronous HTTP clients (\async\_client.php\, \client.php\), WebSocket client (\async\_websocket.php\), and various proxy configurations (\http\_proxy.php\, \http\_proxy\_auth.php\, \https\_proxy.php\). The examples also cover file uploads (\upload\_file.php\), raw socket usage (\raw.php\), and a comprehensive HTTP server template (\server.php\) that handles static files, chunked responses, and gzip compression.
examples/http · high confidence
New async I/O and DNS lookup examples
Added example scripts demonstrating the new asynchronous capabilities: dns\_lookup.php for DNS resolution, exec.php for running external commands asynchronously, read.php and readfile.php for non-blocking file reading, and write.php and writefile.php for non-blocking file writing.
examples/async · high confidence
New event loop and I/O examples
Added new example scripts demonstrating the usage of the event loop and I/O handling in the \examples/event\ directory. This includes \cycle.php\ for event loop cycling, \inotify.php\ for inotify integration, \sockets.php\ for socket-based event handling, \stdin.php\ for standard input events, \stream.php\ for stream-based I/O, and \test.php\ for basic event testing. These examples illustrate how to register and manage file descriptors and timers using the Swoole event system.
examples/event · high confidence
New examples for the swoole\_table API
Added five new example scripts demonstrating the usage of the \swoole\_table\ class. The \array.php\ and \set.php\ files show basic table creation, column definition, and data insertion via array assignment and the \set()\ method. The \iterator.php\ file demonstrates iterating over table elements and using the \get()\ and \del()\ methods. The \server.php\ example integrates \swoole\_table\ with a \swoole\_server\ to store and retrieve connection information. Finally, \simulation.php\ provides a stress-test style script to verify table usability under continuous set/delete operations.
examples/table · high confidence
New factory implementations for process and thread modes
The \src/factory\ directory now contains new C source files (\Factory.c\, \FactoryProcess.c\, \FactoryThread.c\) that implement the \swFactory\ interface for different server modes. \FactoryProcess.c\ introduces a process-based factory that manages worker processes and handles task dispatching via pipes, while \FactoryThread.c\ provides a thread-based factory using a thread pool for task execution. These changes establish the underlying architecture for Swoole's process and thread execution models, enabling the server to route and process requests through dedicated worker processes or threads.
src/factory · high confidence
New header files for core Swoole components
The \include\ directory now contains the C header files for the Swoole core, including \Client.h\, \Connection.h\, \Server.h\, \async.h\, \atomic.h\, \base64.h\, \buffer.h\, \coroutine.h\, \error.h\, \hash.h\, \hashmap.h\, \heap.h\, and \RingQueue.h\. These headers define the internal structures and function prototypes for the client, server, and asynchronous I/O modules, establishing the public API for the C/C++ extension.
include · high confidence
New lock implementations for synchronization primitives
Added new lock implementations for atomic, condition variable, file, mutex, read-write, semaphore, and spin locks. These provide the underlying synchronization primitives used by the Swoole runtime.
src/lock · high confidence
New memory management subsystem with multiple allocator backends
The src/memory directory now contains a new memory management subsystem, introducing several distinct memory allocators and utilities. A RingBuffer allocator is added for efficient circular buffer memory management. A FixedPool allocator provides fixed-size memory allocation. A Global memory allocator manages large, page-sized memory blocks. A Malloc wrapper provides standard malloc/free semantics. ShareMemory utilities enable shared memory allocation and management. Finally, a Table implementation provides a hash-map-like data structure with configurable conflict handling and memory size calculation. These components collectively replace or supplement previous memory handling mechanisms, offering more granular control over memory allocation strategies within the application.
src/memory · high confidence
New protocol parsers for HTTP, HTTP/2, WebSocket, and other protocols
Added new protocol parsing implementations for HTTP, HTTP/2, WebSocket, Base64, Mqtt, Redis, SSL, SHA1, Socks5, and MimeTypes. These changes introduce structured parsers for handling different network protocols, enabling the server to correctly interpret and process data from various sources. The addition of these parsers allows for more robust and secure handling of incoming and outgoing data across multiple protocols.
src/protocol · high confidence
New server example scripts for dispatch, messaging, and tracing
Added multiple new example scripts in the examples/server directory to demonstrate advanced Swoole server capabilities. These include dispatch strategies (ip\_dispatch, uid\_dispatch, dispatch\_func, dispatch\_stream), inter-process communication (pipe\_message), slow request tracing (trace), async reloading (reload\_aysnc), and integration with external systems like ZeroMQ (zmq) and Unix domain sockets (unix\_stream). The examples also cover multi-port listening (listen\_1k\_port), fixed-header packet handling (fixed\_header\_server), and single-process modes (single).
examples/server · high confidence
Behavioural changes
Add atomic operation examples
Added example scripts demonstrating the usage of the new Swoole atomic classes. The 'atomic' directory now includes 'long.php' to showcase the Swoole\\Atomic\\Long class for 64-bit atomic operations, 'test.php' for the standard swoole\_atomic class, and 'wait.php' to illustrate process synchronization using wait and wakeup methods.
examples/atomic · medium confidence
Add mmap example demonstrating memory-mapped file operations
A new example script (mmap.php) was added to the examples/mmap directory. It demonstrates how to use the Swoole mmap module to create and write to a memory-mapped file, specifically showing the usage of swoole\\mmap::open, fwrite, fflush, and fclose for file operations.
examples/mmap · medium confidence
Refactored and expanded asynchronous I/O, timer, and signal handling subsystems
The asynchronous I/O subsystem now supports a thread-pool based fallback (swAioBase) alongside the native Linux AIO implementation, with new functions for reading and writing files, DNS lookups, and stream line retrieval. The timer module has been refactored to use timerfd on modern Linux kernels, with a pipe-based fallback for older systems. Signal handling has been updated to support signalfd, and message queue operations now include statistics and blocking mode configuration.
src/os · high confidence
Refactored and unified the reactor event loop implementation
The reactor module has been refactored to provide a unified interface for handling I/O events across different operating systems. The code now supports multiple event notification mechanisms, including Linux epoll, BSD kqueue, POSIX poll, and the legacy select system, allowing the framework to automatically select the most efficient backend for the current platform. This change improves performance and stability by leveraging native OS capabilities for high-concurrency network processing.
src/reactor · high confidence
Fixes
Fix HTTP/2 client crash when compiled with --enable-sockets
Resolves a crash in the HTTP/2 client module that occurred when the extension was compiled with the --enable-sockets flag. This fix ensures stable operation of HTTP/2 client connections under this specific build configuration.
(repo-wide) · high confidence
Test coverage
Added HTTP/2 client test coverage; Added PHP test cases for Swoole server port and TCP EOF handling; Added comprehensive test coverage for async Swoole client operations; Added memory leak tests for Swoole clients and servers; Added new Redis coroutine test cases; Added test for handling large Redis packets; Added test infrastructure and sample data for automated testing; Added test infrastructure and unit tests for Swoole components; Added test utility classes and functions for Swoole integration testing; Added tests for Swoole Coroutine Redis defer and connection handling; Added tests for Swoole async I/O operations; Added tests for Swoole sync client protocols and utility functions; Added tests for forbidden coroutine cases; Added tests for swoole\_mysql; Added unit tests for Swoole API components; Added unit tests for Swoole HTTP server features; Added unit tests for Swoole Redis; Added unit tests for Swoole process management; Added unit tests for Swoole table operations; Added unit tests for Swoole timer functions; Added unit tests for the swoole\_serialize extension; Expanded test coverage for Swoole coroutine features; Expanded test coverage for Swoole server and atomic operations; Expanded test coverage for the Swoole HTTP client.
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 37 → 37 (+0.0)
- Rubric changed (rubric-2026.08.18 → rubric-2026.08.19) — scores are not directly comparable.
Lenses
- Code Health 100 → 100 (+0.0)
- Architecture 100 → 100 (+0.0)
- Maturity 37 → 37 (+0.0)
- Readiness 33 → 33 (+0.0)
- Security 24 → 24 (+0.0)
Findings
- No change — the same findings as the prior survey.
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
osenv/swoole-src was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 5 August 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit d047dd81c878c93ecb1a7e32e590bf526f94daa7 — the exact code this score is about.
- Scored under rubric-2026.08.19 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer latest.