{"owner":"swoole","repo":"swoole-src","hasSkills":true,"hasMcp":false,"mcpConfig":null,"found":["CLAUDE.md"],"skills":{"CLAUDE.md":"# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n## Build & Test Commands\n\n### Traditional PHP Extension Build (for production use)\n```bash\nphpize && ./configure [flags] && make -j$(nproc) && make install\n```\nCommon configure flags: `--enable-sockets`, `--enable-mysqlnd`, `--enable-swoole-curl`, `--enable-cares`, `--enable-swoole-pgsql`, `--with-openssl-dir=DIR`, `--enable-swoole-thread`, `--enable-iouring`, `--enable-uring-socket`\n\n### Developer Build (with ASAN + warnings)\n```bash\nphpize && ./configure --enable-swoole-dev --enable-debug-log --enable-sockets --enable-mysqlnd --enable-swoole-curl\n```\n\n### CMake Build (for core lib development without full PHP build)\n```bash\nmkdir -p build && cd build && cmake .. && make -j$(nproc)\n```\nThis produces `lib/libswoole.so` (core library) and `core-tests` (Google Test binary for C++ tests).\n\nOptional CMake flags: `-DCODE_COVERAGE=ON`, `-Denable_asan=ON`, `-Denable_thread=ON`, `-Dphp_dir=PATH`, `-Dopenssl_dir=PATH`\n\n### Running Tests\n\n**PHP tests** (phpt format, run from repo root):\n```bash\n# Run all tests\nphp run-tests.php tests/\n\n# Run a single test\nphp run-tests.php tests/swoole_coroutine/array.phpt\n\n# Run a specific test directory\nphp run-tests.php tests/swoole_http_server/\n```\nRequires Swoole extension installed. Tests use phpt format (PHP's standard test format with `--FILE--` / `--EXPECT--` sections). Environment variables: `SWOOLE_DEBUG`, `SWOOLE_TRACE_FLAGS`.\n\n**Core C++ tests** (Google Test, requires CMake build):\n```bash\nmkdir -p build && cd build && cmake .. && make -j$(nproc)\n./core-tests                           # run all\n./core-tests --gtest_filter=\"Server.*\" # run subset\n```\n\n### Code Style (PHP)\n```bash\ncomposer install -d tests/include/lib  # install php-cs-fixer\n./php-cs-fix                           # fix code style\n```\n\n## Architecture\n\n### Two-Layer Structure\n\nSwoole is a PHP extension with a C++ core library underneath:\n\n- **`src/`** — Core C++ library (`libswoole`). Platform-agnostic event loop, coroutine engine, networking, and protocols. Does NOT depend on PHP.\n- **`ext-src/`** — PHP extension layer (`ext-swoole`). Bridges the core library to PHP via Zend Engine APIs (classes, functions, resource types). Every file here corresponds to a PHP-facing class or feature.\n- **`thirdparty/`** — Bundled third-party code (hiredis, llhttp, nghttp2, boost context ASM, multipart parser, PHP internal shims).\n\n### Key Source Subsystems (`src/`)\n\n| Directory | Purpose |\n|-----------|---------|\n| `core/` | Base utilities: logging, timers, string handling, error codes, channel, buffer |\n| `reactor/` | Event loop implementations: **epoll** (Linux), **kqueue** (macOS/BSD), **poll** (fallback), **iocp** (Windows) |\n| `coroutine/` | Coroutine scheduler, context switching (boost asm/ucontext/thread), socket/file hooks, io_uring integration |\n| `server/` | Server modes: multi-process (`master.cc`/`manager.cc`/`worker.cc`), multi-thread, task workers, static file handler |\n| `network/` | Low-level networking: TCP/UDP client/server sockets, DNS resolution |\n| `protocol/` | Wire protocols: HTTP/1.1, HTTP/2, WebSocket, MQTT, Redis protocol, SOCKS5 proxy, SSL/TLS/DTLS |\n| `lock/` | Synchronization primitives: mutex, rwlock, spinlock, barrier, coroutine-aware lock |\n| `memory/` | Shared memory data structures: Table, LRU cache, ring buffer |\n| `os/` | OS abstractions: signals, pipes, process pool, message queue |\n| `wrapper/` | C++ header-only wrappers for coroutine-aware PHP stream functions |\n\n### Coroutine Engine\n\nCoroutines are cooperatively-scheduled user-space threads. Key concepts:\n- Context switching uses **boost.context ASM** (per CPU arch) or POSIX `ucontext` or `SW_USE_THREAD_CONTEXT`.\n- The **hook** mechanism (`src/coroutine/hook.cc`) intercepts blocking PHP stream/network calls and converts them to coroutine-yielding async operations.\n- Runtime hooks (`SWOOLE_HOOK_ALL`) transparently make `curl`, `mysqli`, `pdo`, `redis`, `stream_socket_*`, `sleep`, `file_get_contents` coroutine-aware.\n\n### Server Models\n\n- **SWOOLE_PROCESS** (default): One Manager process forks N Worker processes. Workers handle connections via event loop. Task workers for async task dispatch.\n- **SWOOLE_BASE**: Single-process, all workers share the event loop (no IPC overhead).\n- **Thread mode** (`--enable-swoole-thread`): Uses pthreads instead of processes. Requires PHP ZTS.\n\n### PHP Extension Layer (`ext-src/`)\n\nEntry point: `ext-src/php_swoole.cc`. Each file maps to Swoole PHP classes:\n- `swoole_server.cc` → `Swoole\\Server`\n- `swoole_http_server.cc` → `Swoole\\Http\\Server`\n- `swoole_coroutine.cc` → `Swoole\\Coroutine` / `Co`\n- `swoole_runtime.cc` → `Swoole\\Runtime`\n- `swoole_curl.cc` → `Swoole\\Coroutine\\Curl`\n- etc.\n\nInternal header `ext-src/php_swoole_private.h` is the central include for the PHP layer.\n\n## CI Filter Tags\n\nCommit messages can contain filter tags to restrict which CI jobs run. Only CI jobs matching the tag execute; non-matching jobs are skipped. Behavior differs between Compile/Core tests (skip by default when filter present) and Unit tests (run by default when filter present):\n\n| Tag | Jobs Enabled |\n|-----|-------------|\n| `[ubuntu]` | Ubuntu compile tests |\n| `[alpine]` | Alpine compile tests |\n| `[macos]` | macOS compile tests |\n| `[windows]` | Windows tests |\n| `[core]` | Core (C++) tests |\n| `[swoole_*]` | Specific unit test directories (e.g., `[swoole_coroutine]`, `[swoole_server]`), plus framework tests |\n| no filter | All jobs run |\n\nExamples:\n- `test --filter=[swoole_coroutine]` — only `swoole_coroutine/` unit tests\n- `test --filter=[windows]` — only Windows unit tests\n\n## Platform Support\n\n- **Linux** (primary): epoll, io_uring, signalfd, eventfd, sendfile. Full feature set.\n- **macOS**: kqueue. Some features unavailable (io_uring, signalfd, eventfd).\n- **Windows/Cygwin** (experimental): IOCP reactor. See `config.w32`, `ext-src/swoole_event.cc`.\n- **Architectures**: x86_64, ARM64, ARM32, MIPS32/64, RISC-V 64, LoongArch 64 (each needs matching ASM context in `thirdparty/boost/asm/`).\n\n## include/ Structure\n\nHeaders in `include/` are the public API of `libswoole`. Key headers:\n- `swoole.h` — master include, pulls in everything\n- `swoole_config.h` — compile-time feature flags\n- `swoole_version.h` — version macros\n- `swoole_server.h` — server structs and API\n- `swoole_coroutine.h` — coroutine scheduler types\n- `swoole_reactor.h` — event loop interface\n- `swoole_http.h`, `swoole_http2.h`, `swoole_websocket.h` — protocol types\n- `swoole_socket.h`, `swoole_socket_hook.h` — socket and hook interfaces\n- `swoole_thread.h` — threading API\n- `swoole_iouring.h` — io_uring integration\n- `swoole_win32.h`, `swoole_iocp.h`, `swoole_iocp_socket.h` — Windows support\n"},"files":{"CLAUDE.md":"# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n## Build & Test Commands\n\n### Traditional PHP Extension Build (for production use)\n```bash\nphpize && ./configure [flags] && make -j$(nproc) && make install\n```\nCommon configure flags: `--enable-sockets`, `--enable-mysqlnd`, `--enable-swoole-curl`, `--enable-cares`, `--enable-swoole-pgsql`, `--with-openssl-dir=DIR`, `--enable-swoole-thread`, `--enable-iouring`, `--enable-uring-socket`\n\n### Developer Build (with ASAN + warnings)\n```bash\nphpize && ./configure --enable-swoole-dev --enable-debug-log --enable-sockets --enable-mysqlnd --enable-swoole-curl\n```\n\n### CMake Build (for core lib development without full PHP build)\n```bash\nmkdir -p build && cd build && cmake .. && make -j$(nproc)\n```\nThis produces `lib/libswoole.so` (core library) and `core-tests` (Google Test binary for C++ tests).\n\nOptional CMake flags: `-DCODE_COVERAGE=ON`, `-Denable_asan=ON`, `-Denable_thread=ON`, `-Dphp_dir=PATH`, `-Dopenssl_dir=PATH`\n\n### Running Tests\n\n**PHP tests** (phpt format, run from repo root):\n```bash\n# Run all tests\nphp run-tests.php tests/\n\n# Run a single test\nphp run-tests.php tests/swoole_coroutine/array.phpt\n\n# Run a specific test directory\nphp run-tests.php tests/swoole_http_server/\n```\nRequires Swoole extension installed. Tests use phpt format (PHP's standard test format with `--FILE--` / `--EXPECT--` sections). Environment variables: `SWOOLE_DEBUG`, `SWOOLE_TRACE_FLAGS`.\n\n**Core C++ tests** (Google Test, requires CMake build):\n```bash\nmkdir -p build && cd build && cmake .. && make -j$(nproc)\n./core-tests                           # run all\n./core-tests --gtest_filter=\"Server.*\" # run subset\n```\n\n### Code Style (PHP)\n```bash\ncomposer install -d tests/include/lib  # install php-cs-fixer\n./php-cs-fix                           # fix code style\n```\n\n## Architecture\n\n### Two-Layer Structure\n\nSwoole is a PHP extension with a C++ core library underneath:\n\n- **`src/`** — Core C++ library (`libswoole`). Platform-agnostic event loop, coroutine engine, networking, and protocols. Does NOT depend on PHP.\n- **`ext-src/`** — PHP extension layer (`ext-swoole`). Bridges the core library to PHP via Zend Engine APIs (classes, functions, resource types). Every file here corresponds to a PHP-facing class or feature.\n- **`thirdparty/`** — Bundled third-party code (hiredis, llhttp, nghttp2, boost context ASM, multipart parser, PHP internal shims).\n\n### Key Source Subsystems (`src/`)\n\n| Directory | Purpose |\n|-----------|---------|\n| `core/` | Base utilities: logging, timers, string handling, error codes, channel, buffer |\n| `reactor/` | Event loop implementations: **epoll** (Linux), **kqueue** (macOS/BSD), **poll** (fallback), **iocp** (Windows) |\n| `coroutine/` | Coroutine scheduler, context switching (boost asm/ucontext/thread), socket/file hooks, io_uring integration |\n| `server/` | Server modes: multi-process (`master.cc`/`manager.cc`/`worker.cc`), multi-thread, task workers, static file handler |\n| `network/` | Low-level networking: TCP/UDP client/server sockets, DNS resolution |\n| `protocol/` | Wire protocols: HTTP/1.1, HTTP/2, WebSocket, MQTT, Redis protocol, SOCKS5 proxy, SSL/TLS/DTLS |\n| `lock/` | Synchronization primitives: mutex, rwlock, spinlock, barrier, coroutine-aware lock |\n| `memory/` | Shared memory data structures: Table, LRU cache, ring buffer |\n| `os/` | OS abstractions: signals, pipes, process pool, message queue |\n| `wrapper/` | C++ header-only wrappers for coroutine-aware PHP stream functions |\n\n### Coroutine Engine\n\nCoroutines are cooperatively-scheduled user-space threads. Key concepts:\n- Context switching uses **boost.context ASM** (per CPU arch) or POSIX `ucontext` or `SW_USE_THREAD_CONTEXT`.\n- The **hook** mechanism (`src/coroutine/hook.cc`) intercepts blocking PHP stream/network calls and converts them to coroutine-yielding async operations.\n- Runtime hooks (`SWOOLE_HOOK_ALL`) transparently make `curl`, `mysqli`, `pdo`, `redis`, `stream_socket_*`, `sleep`, `file_get_contents` coroutine-aware.\n\n### Server Models\n\n- **SWOOLE_PROCESS** (default): One Manager process forks N Worker processes. Workers handle connections via event loop. Task workers for async task dispatch.\n- **SWOOLE_BASE**: Single-process, all workers share the event loop (no IPC overhead).\n- **Thread mode** (`--enable-swoole-thread`): Uses pthreads instead of processes. Requires PHP ZTS.\n\n### PHP Extension Layer (`ext-src/`)\n\nEntry point: `ext-src/php_swoole.cc`. Each file maps to Swoole PHP classes:\n- `swoole_server.cc` → `Swoole\\Server`\n- `swoole_http_server.cc` → `Swoole\\Http\\Server`\n- `swoole_coroutine.cc` → `Swoole\\Coroutine` / `Co`\n- `swoole_runtime.cc` → `Swoole\\Runtime`\n- `swoole_curl.cc` → `Swoole\\Coroutine\\Curl`\n- etc.\n\nInternal header `ext-src/php_swoole_private.h` is the central include for the PHP layer.\n\n## CI Filter Tags\n\nCommit messages can contain filter tags to restrict which CI jobs run. Only CI jobs matching the tag execute; non-matching jobs are skipped. Behavior differs between Compile/Core tests (skip by default when filter present) and Unit tests (run by default when filter present):\n\n| Tag | Jobs Enabled |\n|-----|-------------|\n| `[ubuntu]` | Ubuntu compile tests |\n| `[alpine]` | Alpine compile tests |\n| `[macos]` | macOS compile tests |\n| `[windows]` | Windows tests |\n| `[core]` | Core (C++) tests |\n| `[swoole_*]` | Specific unit test directories (e.g., `[swoole_coroutine]`, `[swoole_server]`), plus framework tests |\n| no filter | All jobs run |\n\nExamples:\n- `test --filter=[swoole_coroutine]` — only `swoole_coroutine/` unit tests\n- `test --filter=[windows]` — only Windows unit tests\n\n## Platform Support\n\n- **Linux** (primary): epoll, io_uring, signalfd, eventfd, sendfile. Full feature set.\n- **macOS**: kqueue. Some features unavailable (io_uring, signalfd, eventfd).\n- **Windows/Cygwin** (experimental): IOCP reactor. See `config.w32`, `ext-src/swoole_event.cc`.\n- **Architectures**: x86_64, ARM64, ARM32, MIPS32/64, RISC-V 64, LoongArch 64 (each needs matching ASM context in `thirdparty/boost/asm/`).\n\n## include/ Structure\n\nHeaders in `include/` are the public API of `libswoole`. Key headers:\n- `swoole.h` — master include, pulls in everything\n- `swoole_config.h` — compile-time feature flags\n- `swoole_version.h` — version macros\n- `swoole_server.h` — server structs and API\n- `swoole_coroutine.h` — coroutine scheduler types\n- `swoole_reactor.h` — event loop interface\n- `swoole_http.h`, `swoole_http2.h`, `swoole_websocket.h` — protocol types\n- `swoole_socket.h`, `swoole_socket_hook.h` — socket and hook interfaces\n- `swoole_thread.h` — threading API\n- `swoole_iouring.h` — io_uring integration\n- `swoole_win32.h`, `swoole_iocp.h`, `swoole_iocp_socket.h` — Windows support\n"},"items":[{"name":"CLAUDE.md","path":"CLAUDE.md","title":"CLAUDE.md","content":"# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n## Build & Test Commands\n\n### Traditional PHP Extension Build (for production use)\n```bash\nphpize && ./configure [flags] && make -j$(nproc) && make install\n```\nCommon configure flags: `--enable-sockets`, `--enable-mysqlnd`, `--enable-swoole-curl`, `--enable-cares`, `--enable-swoole-pgsql`, `--with-openssl-dir=DIR`, `--enable-swoole-thread`, `--enable-iouring`, `--enable-uring-socket`\n\n### Developer Build (with ASAN + warnings)\n```bash\nphpize && ./configure --enable-swoole-dev --enable-debug-log --enable-sockets --enable-mysqlnd --enable-swoole-curl\n```\n\n### CMake Build (for core lib development without full PHP build)\n```bash\nmkdir -p build && cd build && cmake .. && make -j$(nproc)\n```\nThis produces `lib/libswoole.so` (core library) and `core-tests` (Google Test binary for C++ tests).\n\nOptional CMake flags: `-DCODE_COVERAGE=ON`, `-Denable_asan=ON`, `-Denable_thread=ON`, `-Dphp_dir=PATH`, `-Dopenssl_dir=PATH`\n\n### Running Tests\n\n**PHP tests** (phpt format, run from repo root):\n```bash\n# Run all tests\nphp run-tests.php tests/\n\n# Run a single test\nphp run-tests.php tests/swoole_coroutine/array.phpt\n\n# Run a specific test directory\nphp run-tests.php tests/swoole_http_server/\n```\nRequires Swoole extension installed. Tests use phpt format (PHP's standard test format with `--FILE--` / `--EXPECT--` sections). Environment variables: `SWOOLE_DEBUG`, `SWOOLE_TRACE_FLAGS`.\n\n**Core C++ tests** (Google Test, requires CMake build):\n```bash\nmkdir -p build && cd build && cmake .. && make -j$(nproc)\n./core-tests                           # run all\n./core-tests --gtest_filter=\"Server.*\" # run subset\n```\n\n### Code Style (PHP)\n```bash\ncomposer install -d tests/include/lib  # install php-cs-fixer\n./php-cs-fix                           # fix code style\n```\n\n## Architecture\n\n### Two-Layer Structure\n\nSwoole is a PHP extension with a C++ core library underneath:\n\n- **`src/`** — Core C++ library (`libswoole`). Platform-agnostic event loop, coroutine engine, networking, and protocols. Does NOT depend on PHP.\n- **`ext-src/`** — PHP extension layer (`ext-swoole`). Bridges the core library to PHP via Zend Engine APIs (classes, functions, resource types). Every file here corresponds to a PHP-facing class or feature.\n- **`thirdparty/`** — Bundled third-party code (hiredis, llhttp, nghttp2, boost context ASM, multipart parser, PHP internal shims).\n\n### Key Source Subsystems (`src/`)\n\n| Directory | Purpose |\n|-----------|---------|\n| `core/` | Base utilities: logging, timers, string handling, error codes, channel, buffer |\n| `reactor/` | Event loop implementations: **epoll** (Linux), **kqueue** (macOS/BSD), **poll** (fallback), **iocp** (Windows) |\n| `coroutine/` | Coroutine scheduler, context switching (boost asm/ucontext/thread), socket/file hooks, io_uring integration |\n| `server/` | Server modes: multi-process (`master.cc`/`manager.cc`/`worker.cc`), multi-thread, task workers, static file handler |\n| `network/` | Low-level networking: TCP/UDP client/server sockets, DNS resolution |\n| `protocol/` | Wire protocols: HTTP/1.1, HTTP/2, WebSocket, MQTT, Redis protocol, SOCKS5 proxy, SSL/TLS/DTLS |\n| `lock/` | Synchronization primitives: mutex, rwlock, spinlock, barrier, coroutine-aware lock |\n| `memory/` | Shared memory data structures: Table, LRU cache, ring buffer |\n| `os/` | OS abstractions: signals, pipes, process pool, message queue |\n| `wrapper/` | C++ header-only wrappers for coroutine-aware PHP stream functions |\n\n### Coroutine Engine\n\nCoroutines are cooperatively-scheduled user-space threads. Key concepts:\n- Context switching uses **boost.context ASM** (per CPU arch) or POSIX `ucontext` or `SW_USE_THREAD_CONTEXT`.\n- The **hook** mechanism (`src/coroutine/hook.cc`) intercepts blocking PHP stream/network calls and converts them to coroutine-yielding async operations.\n- Runtime hooks (`SWOOLE_HOOK_ALL`) transparently make `curl`, `mysqli`, `pdo`, `redis`, `stream_socket_*`, `sleep`, `file_get_contents` coroutine-aware.\n\n### Server Models\n\n- **SWOOLE_PROCESS** (default): One Manager process forks N Worker processes. Workers handle connections via event loop. Task workers for async task dispatch.\n- **SWOOLE_BASE**: Single-process, all workers share the event loop (no IPC overhead).\n- **Thread mode** (`--enable-swoole-thread`): Uses pthreads instead of processes. Requires PHP ZTS.\n\n### PHP Extension Layer (`ext-src/`)\n\nEntry point: `ext-src/php_swoole.cc`. Each file maps to Swoole PHP classes:\n- `swoole_server.cc` → `Swoole\\Server`\n- `swoole_http_server.cc` → `Swoole\\Http\\Server`\n- `swoole_coroutine.cc` → `Swoole\\Coroutine` / `Co`\n- `swoole_runtime.cc` → `Swoole\\Runtime`\n- `swoole_curl.cc` → `Swoole\\Coroutine\\Curl`\n- etc.\n\nInternal header `ext-src/php_swoole_private.h` is the central include for the PHP layer.\n\n## CI Filter Tags\n\nCommit messages can contain filter tags to restrict which CI jobs run. Only CI jobs matching the tag execute; non-matching jobs are skipped. Behavior differs between Compile/Core tests (skip by default when filter present) and Unit tests (run by default when filter present):\n\n| Tag | Jobs Enabled |\n|-----|-------------|\n| `[ubuntu]` | Ubuntu compile tests |\n| `[alpine]` | Alpine compile tests |\n| `[macos]` | macOS compile tests |\n| `[windows]` | Windows tests |\n| `[core]` | Core (C++) tests |\n| `[swoole_*]` | Specific unit test directories (e.g., `[swoole_coroutine]`, `[swoole_server]`), plus framework tests |\n| no filter | All jobs run |\n\nExamples:\n- `test --filter=[swoole_coroutine]` — only `swoole_coroutine/` unit tests\n- `test --filter=[windows]` — only Windows unit tests\n\n## Platform Support\n\n- **Linux** (primary): epoll, io_uring, signalfd, eventfd, sendfile. Full feature set.\n- **macOS**: kqueue. Some features unavailable (io_uring, signalfd, eventfd).\n- **Windows/Cygwin** (experimental): IOCP reactor. See `config.w32`, `ext-src/swoole_event.cc`.\n- **Architectures**: x86_64, ARM64, ARM32, MIPS32/64, RISC-V 64, LoongArch 64 (each needs matching ASM context in `thirdparty/boost/asm/`).\n\n## include/ Structure\n\nHeaders in `include/` are the public API of `libswoole`. Key headers:\n- `swoole.h` — master include, pulls in everything\n- `swoole_config.h` — compile-time feature flags\n- `swoole_version.h` — version macros\n- `swoole_server.h` — server structs and API\n- `swoole_coroutine.h` — coroutine scheduler types\n- `swoole_reactor.h` — event loop interface\n- `swoole_http.h`, `swoole_http2.h`, `swoole_websocket.h` — protocol types\n- `swoole_socket.h`, `swoole_socket_hook.h` — socket and hook interfaces\n- `swoole_thread.h` — threading API\n- `swoole_iouring.h` — io_uring integration\n- `swoole_win32.h`, `swoole_iocp.h`, `swoole_iocp_socket.h` — Windows support\n","category":"root","tokens":1698}]}