{"id":13398365,"url":"https://github.com/swoole/swoole-src","last_synced_at":"2026-10-18T21:09:09.380Z","repository":{"id":4033212,"uuid":"5133949","full_name":"swoole/swoole-src","owner":"swoole","description":"🚀 Coroutine-based concurrency library for PHP","archived":false,"fork":false,"pushed_at":"2026-10-12T08:09:02.000Z","size":57600,"stargazers_count":18917,"open_issues_count":40,"forks_count":3149,"subscribers_count":802,"default_branch":"master","last_synced_at":"2026-10-12T08:33:36.291Z","etag":null,"topics":["concurrency","coroutines","event","php","swoole","websocket"],"latest_commit_sha":null,"homepage":"https://www.swoole.com","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swoole.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"accessibility":null,"support":"docs/SUPPORTED.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","claude":null,"gemini":null,"cursor":null,"copilot":null,"dco":null,"cla":null,"disclosure":null}},"created_at":"2012-07-21T13:49:59.000Z","updated_at":"2026-10-12T07:04:34.000Z","dependencies_parsed_at":"2026-10-12T08:28:50.428Z","dependency_job_id":null,"html_url":"https://github.com/swoole/swoole-src","commit_stats":{"total_commits":11087,"total_committers":207,"mean_commits":53.56038647342995,"dds":"0.42040227293226307","last_synced_commit":"1731aa6bb23b0c6c2a64c141c4d740187898ff9d"},"previous_names":["swoole/swoole"],"tags_count":410,"template":false,"template_full_name":null,"purl":"pkg:github/swoole/swoole-src","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swoole%2Fswoole-src","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swoole%2Fswoole-src/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swoole%2Fswoole-src/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swoole%2Fswoole-src/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swoole","download_url":"https://codeload.github.com/swoole/swoole-src/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swoole%2Fswoole-src/sbom","scorecard":{"id":418833,"data":{"date":"2025-08-11","repo":{"name":"github.com/swoole/swoole-src","commit":"809eb827f54f57b94a232fdb6a096add95159e8b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5,"checks":[{"name":"Maintained","score":10,"reason":"30 commit(s) and 20 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":3,"reason":"Found 9/30 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: Dockerfile:3: pin your Docker image by updating ubuntu:22.04 to ubuntu:22.04@sha256:1aa979d85661c488ce030ac292876cf6ed04535d3a237e49f61542d8e5de5ae0","Warn: npmCommand not pinned by hash: run-core-tests.sh:10","Warn: downloadThenRun not pinned by hash: scripts/route.sh:33","Warn: downloadThenRun not pinned by hash: scripts/route.sh:77","Warn: downloadThenRun not pinned by hash: scripts/route.sh:87","Warn: downloadThenRun not pinned by hash: scripts/route.sh:88","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned","Info:   0 out of   4 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T00:39:01.710Z","repository_id":4033212,"created_at":"2025-08-19T00:39:01.710Z","updated_at":"2025-08-19T00:39:01.710Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":344872684,"owners_count":38341851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-10-03T21:59:58.778Z","status":"online","status_checked_at":"2026-10-18T02:00:06.448Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","coroutines","event","php","swoole","websocket"],"created_at":"2024-07-30T19:00:23.920Z","updated_at":"2026-10-18T21:09:09.373Z","avatar_url":"https://github.com/swoole.png","language":"C++","funding_links":[],"categories":["C","C++","Other","Table of Contents","PHP","武器库","异步","Swoole"],"sub_categories":["Scientific Computing","Event","后端","Framework"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/swoole-logo.svg\" width=\"200\" height=\"120\" alt=\"Swoole logo\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eSwoole\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eAn event-driven networking engine and coroutine runtime for PHP\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/swoole/swoole-src/actions/workflows/ext.yml\"\u003e\u003cimg src=\"https://github.com/swoole/swoole-src/actions/workflows/ext.yml/badge.svg\" alt=\"Extension build\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/swoole/swoole-src/actions/workflows/core.yml\"\u003e\u003cimg src=\"https://github.com/swoole/swoole-src/actions/workflows/core.yml/badge.svg\" alt=\"Core tests\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/swoole/swoole-src/actions/workflows/unit.yml\"\u003e\u003cimg src=\"https://github.com/swoole/swoole-src/actions/workflows/unit.yml/badge.svg\" alt=\"PHP tests\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/swoole/swoole-src/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/swoole/swoole-src\" alt=\"Latest release\"\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/swoole/swoole-src\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nSwoole 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.\n\n\u003e **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](docs/SUPPORTED.md) for its PHP compatibility and maintenance status.\n\n## At a glance\n\n| Capability | Main APIs | Typical use |\n| --- | --- | --- |\n| Event-driven servers | `Swoole\\Server`, `Swoole\\Event` | TCP, UDP, Unix sockets, connection events |\n| Coroutines | `Swoole\\Coroutine`, `Channel`, `Socket` | Concurrent I/O and task coordination |\n| HTTP and WebSocket | `Swoole\\Http\\Server`, `Swoole\\WebSocket\\Server` | APIs, streaming responses, real-time messaging |\n| Coroutine clients | `Swoole\\Coroutine\\Client`, `Swoole\\Coroutine\\Http\\Client` | Calls to TCP and HTTP upstream services |\n| Runtime hooks | `Swoole\\Runtime` | Coroutine-aware behavior for supported PHP functions |\n| Processes and shared data | `Swoole\\Process`, `Swoole\\Table`, atomics | Background work and interprocess state |\n| Timers and system I/O | `Swoole\\Timer`, `Swoole\\Coroutine\\System` | Scheduled work, file and process operations |\n\n## How Swoole works\n\nThe 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.\n\nCoroutines 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.\n\nSwoole 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.\n\n## Functional modules\n\n### Servers and network protocols\n\n`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.\n\nChoose the server API that matches the protocol and lifecycle:\n\n| Requirement | Starting point |\n| --- | --- |\n| Custom TCP/UDP protocol, multiple ports, or task workers | `Swoole\\Server` |\n| HTTP API with request callbacks and worker processes | `Swoole\\Http\\Server` |\n| HTTP service controlled from a coroutine | `Swoole\\Coroutine\\Http\\Server` |\n| WebSocket handshake and bidirectional frames | `Swoole\\WebSocket\\Server` |\n\nSee the [TCP server](examples/server/tcp_server.php) and [multiple-port server](examples/server/multi_port.php) examples. Server callbacks can use `task()` to dispatch work to task workers and `sendMessage()` for messages between workers.\n\n### Coroutines and coordination\n\n`Swoole\\Coroutine\\run()` starts a coroutine environment, and `go()` starts a coroutine. `Swoole\\Coroutine\\Socket` and `Swoole\\Coroutine\\System` expose I/O operations that cooperate with the scheduler. `Channel` passes values between coroutines; the PHP library also provides `WaitGroup` and `Barrier` for waiting on groups of tasks. Set timeouts for upstream calls and handle cancellation or failures explicitly.\n\n`Swoole\\Runtime::enableCoroutine()` hooks selected blocking PHP functions so they can yield inside a coroutine. Depending on the hook flags, build options, and loaded PHP extensions, this can cover streams, files, sleep functions, cURL, and supported database operations. Hooks do not transform arbitrary third-party C library calls. Use the explicit coroutine client or Socket APIs when precise I/O behavior matters.\n\n### HTTP, HTTP/2, and WebSocket\n\n`Swoole\\Http\\Server` serves HTTP through request callbacks; `Swoole\\Coroutine\\Http\\Server` offers a coroutine-managed server. Request and response APIs cover headers, cookies, uploads, status codes, file delivery, and streamed output. The HTTP/2 implementation supports multiplexed streams, while WebSocket provides upgrade handling and frame encoding and decoding. Compression and TLS depend on the relevant build options and environment.\n\nCoroutine HTTP and HTTP/2 clients call upstream services without occupying a worker while waiting for I/O. For examples and edge cases, see the [HTTP/2 examples](examples/http2/) and [WebSocket tests](tests/swoole_websocket_server/). Applications still need to define their own message formats, authentication, and reconnect behavior.\n\n### Clients, DNS, and asynchronous system operations\n\nCoroutine TCP/UDP clients, HTTP clients, and the lower-level Socket API offer different levels of control over connection setup, timeouts, and message framing. `Swoole\\Coroutine\\System` provides file and process operations. Optional c-ares integration supports DNS resolution; optional io_uring integration provides additional asynchronous I/O paths on Linux.\n\nFor database access, combine the appropriate PHP driver with supported runtime hooks, or use the PHP library's PDO, MySQLi, and Redis connection pools. A pool manages connection reuse; whether an operation yields depends on the driver and hook configuration.\n\n### Processes, threads, and the PHP library\n\n`Swoole\\Process` and `Swoole\\Process\\Pool` manage independent workers. `Swoole\\Table` holds structured data shared between processes, and atomic values and messages support coordination. A table is useful for small, frequently accessed state; use a database for persistence or complex queries.\n\nThread APIs are optional and require a ZTS build of PHP. Use Swoole's thread-safe containers for data shared by threads rather than assuming ordinary PHP variables are safe to share. The bundled `library/src/core/` directory also includes FastCGI, name resolvers, remote objects, connection pools, and other utilities. Available features can differ between Swoole branches.\n\n## Quick start\n\n### Install\n\nInstall a released version through PECL:\n\n```bash\npecl install swoole\n```\n\nTo build the checked-out source, install PHP development tools and a C/C++ compiler, then run:\n\n```bash\nphpize\n./configure\nmake -j\"$(nproc)\"\nsudo make install\n```\n\nAdd `extension=swoole.so` to the `php.ini` used by the PHP CLI and verify with `php --ri swoole`. To load it for one command instead, use `php -d extension=swoole.so --ri swoole`. Run `./configure --help` before enabling optional integrations.\n\n### Start an HTTP server\n\nSave this example as `server.php`:\n\n```php\n\u003c?php\n\n$server = new Swoole\\Http\\Server('127.0.0.1', 9501);\n$server-\u003eset(['worker_num' =\u003e 2]);\n$server-\u003eon('request', static function ($request, $response): void {\n    $response-\u003eheader('Content-Type', 'text/plain; charset=utf-8');\n    $response-\u003eend(\"Hello, Swoole!\\n\");\n});\n$server-\u003estart();\n```\n\nRun `php server.php` in one terminal and `curl http://127.0.0.1:9501/` in another. The server keeps running until you stop it with `Ctrl+C`.\n\n### Run concurrent tasks\n\nBoth tasks below wait for 0.1 seconds. While one is waiting, the scheduler can run the other:\n\n```php\n\u003c?php\n\nuse Swoole\\Coroutine\\Channel;\nuse Swoole\\Coroutine\\System;\nuse function Swoole\\Coroutine\\go;\nuse function Swoole\\Coroutine\\run;\n\nrun(function (): void {\n    $results = new Channel(2);\n\n    foreach ([1, 2] as $id) {\n        go(function () use ($id, $results): void {\n            System::sleep(0.1);\n            $results-\u003epush(\"task $id done\");\n        });\n    }\n\n    echo $results-\u003epop(), PHP_EOL;\n    echo $results-\u003epop(), PHP_EOL;\n});\n```\n\n## Optional build features\n\nThe default build provides the basic server and coroutine APIs. Enable integrations when the required system libraries or PHP extensions are available:\n\n| Configure option | Purpose |\n| --- | --- |\n| `--enable-sockets` | Integration with the PHP sockets extension |\n| `--with-openssl-dir=DIR` | TLS/SSL support |\n| `--enable-swoole-curl` | Coroutine cURL support |\n| `--enable-swoole-pgsql` | PostgreSQL support |\n| `--enable-cares` | c-ares DNS support |\n| `--enable-iouring`, `--enable-uring-socket` | Linux io_uring features |\n| `--enable-swoole-thread` | Thread support; requires ZTS PHP |\n\nCheck `./configure --help` and [`config.m4`](config.m4) for the options and dependencies in your branch. See the [Windows notes](docs/windows-native-support.md) for platform-specific details.\n\n## Documentation and development\n\n- [Official documentation](https://wiki.swoole.com/) covers APIs, configuration, and usage.\n- [Examples](examples/) show servers, clients, coroutines, and protocols.\n- [Testing guide](docs/TESTS.md) explains PHP PHPT and C++ GoogleTest workflows.\n- [Supported versions](docs/SUPPORTED.md) and [changelog](docs/CHANGELOG.md) help with branch selection and upgrades.\n- [Repository guidelines](AGENTS.md) describe the source layout, style, tests, and contribution process.\n\nAfter building the extension, run a focused PHP regression test with:\n\n```bash\nPHPT=1 php -n run-tests.php -n -d extension=modules/swoole.so \\\n  tests/swoole_http_server/create_request_large_upgrade.phpt\n```\n\nReport bugs and propose features through [Issues](https://github.com/swoole/swoole-src/issues). Submit code changes through pull requests with relevant tests. Report security issues privately to [team@swoole.com](mailto:team@swoole.com) rather than disclosing them in a public issue.\n\n## License\n\nSwoole is licensed under the [Apache License 2.0](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswoole%2Fswoole-src","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswoole%2Fswoole-src","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswoole%2Fswoole-src/lists"}