Event-driven asynchronous and concurrent networking engine with high performance for PHP.
Event-driven asynchronous and concurrent networking engine with high performance for PHP.
- event-driven
- coroutine
- asynchronous non-blocking
- multi-thread reactor
- multi-process worker
- multi-protocol
- millisecond timer
- built-in tcp/http/websocket/http2 server
- coroutine tcp/http/websocket client
- coroutine read/write file system
- coroutine dns lookup
- support IPv4/IPv6/UnixSocket/TCP/UDP
- support SSL/TLS encrypted transmission
License: Apache2.0
| Version | Release | Download |
| 6.1.1 | 2025-10-30 | swoole-6.1.1.tgz |
| 6.1.0 | 2025-10-24 | swoole-6.1.0.tgz |
| 6.1.0RC2 | 2025-10-13 | swoole-6.1.0RC2.tgz |
| 6.1.0RC1 | 2025-08-30 | swoole-6.1.0RC1.tgz |
| 6.0.2 | 2025-03-22 | swoole-6.0.2.tgz |
| Version | Message |
| 6.1.1 |
- Fixed a compilation failure caused by missing `zlib` dependency. - Optimized the resource management logic in the `curl` module to prevent use-after-free risks. - Resolved the absence of `fdatasync` on macOS systems. - Improved the log output format for coroutine deadlock detection. |
| 6.1.0 |
Major Changes in Swoole 6.1.0 1. Introduction of "Standard Library Extensions" - Revolutionary Syntax Enhancements This is the most eye-catching feature at the language level in this update, allowing object-oriented operations on basic types. Object-Oriented Basic Types: Methods can be called directly on variables of basic types like string, array, and stream (e.g., $text->length()->lower()), greatly improving code readability and development experience. Typed Arrays: Introduced the typed_array syntax, allowing constraints on key and value types, with type checks performed on write operations, enhancing code robustness. 2. A Major Leap in Underlying Architecture and Stability This version invests heavily in code quality and stability, laying a solid foundation for future development. Significant Increase in Test Coverage to 86%: By systematically adding test cases, potential errors are greatly reduced, improving the overall reliability and maintainability of the project. Large-Scale Code Refactoring and Static Analysis: Refactored multiple core modules like Reactor, SSL, and Socket, and used clang-tidy for code standardization, significantly improving code quality and performance. 3. Major Simplification and Unification of the Lock API A groundbreaking refactoring of the core component for concurrent programming – the lock. API Simplification: Removed methods like lockwait and trylock, retaining only three core methods – __construct, lock, and unlock – for Swoole\Coroutine\Lock, Swoole\Lock, and Swoole\Thread\Lock. Unified Behavior: The new API design is closer to PHP's native flock function, reducing the learning curve, and uses standard constants like LOCK_EX | LOCK_NB to implement advanced features such as non-blocking. 4. Enhanced Coroutine Capabilities and Fine-Grained Control More flexible coroutine operation capabilities. Coroutine Cancellation Mechanism: Swoole\Coroutine::cancel() now includes a $throw_exception parameter, allowing a catchable Swoole\Coroutine\CanceledException to be thrown into the target coroutine upon cancellation, enabling safer and more controllable coroutine lifecycle management. Coroutine State Isolation for Serialization Operations: Fixed the issue of global state isolation for serialize/unserialize in coroutine environments. Global variables related to serialization are now automatically saved and restored during coroutine switches, ensuring isolated serialization contexts for each coroutine. 5. Default HTTP Parser Upgrade, Websocket Feature Enhancements, and Platform Compatibility Improvements Important improvements in performance and compatibility. llHTTP Enabled by Default: Replaced the old http_parser with the more performant and modern llhttp, improving the efficiency and reliability of HTTP processing. WebSocket Feature Enhancements: Both client and server now support receiving fragmented messages, actively disconnecting (disconnect), and sending Ping frames (ping), making the WebSocket protocol implementation more complete. Deprecating Select, Embracing Poll: Completely deprecated the flawed select event mechanism. On platforms that do not support epoll/kqueue (like Cygwin), poll is now used by default, enabling support for a large number of concurrent connections on these platforms as well. |
| 6.1.0RC2 |
# New Features - Added the `$throw_exception` parameter to `Swoole\Coroutine::cancel()`, enabling exceptions to be thrown when canceling coroutines. - `Swoole\Coroutine\Http\Client` and `Swoole\Coroutine\Http\Server` now support receiving WebSocket fragmented messages. - Added `disconnect` and `ping` methods to `Swoole\Coroutine\Http\Client` and `Swoole\Coroutine\Http\Server`. - Refactored `Swoole\Coroutine\Lock`, `Swoole\Lock`, and `Swoole\Thread\Lock`, retaining only the `__construct`, `lock`, and `unlock` methods to align more closely with `php flock` in usage. # Bug Fixes - Fixed an issue where `Swoole\Websocket\Server` might still trigger the `onMessage` callback after a handshake failure or connection closure. - Fixed execution errors in `Swoole\Coroutine\Http\Server` caused by inconsistencies between function return types and signatures. - Fixed the issue where `Swoole\Coroutine\Http\Server` did not support enabling HTTP/2. - Fixed the timeout precision conversion issue in `Swoole\Lock::lockwait()`. - Fixed the `ReactorEpoll::add(): failed to add event` warning when using the coroutine-based `curl` module, caused by PHP 8 compatibility adjustments and incomplete cleanup of `keepalive` connections. # Internal Optimizations - Upgraded the `Swoole library` version. - Disabled the `-Wdate-time` warning to resolve compilation errors when using Zig/Clang. - Removed PHP 8.0 compatibility code. - Added the `SWOOLE_ODBC_LIBS` variable in `config.m4`. - Ensured that `timespec.tv_nsec` values are less than `1,000,000,000` to comply with POSIX standards. # Notes - This version is an RC (Release Candidate) and should only be used in testing environments. Do not deploy it in production. - Starting from Swoole 6.1, `Swoole\Coroutine\Http\Client` and `Swoole\Coroutine\Http\Server` will automatically handle WebSocket control frames unless `open_websocket_ping_frame`, `open_websocket_pong_frame`, or `open_websocket_close_frame` are explicitly set. - `Swoole\Coroutine::cancel()` cannot cancel file coroutine operations. Forcibly canceling may cause segmentation faults. - If `--enable-iouring` is enabled, a warning will be thrown if the kernel version or `liburing` version does not meet the requirements. - The `Swoole\Websocket\Server::push` method does not automatically close the connection after sending a close frame. To close the connection, use the `Swoole\Websocket\Server::disconnect()` method. - When handling control frames, the Swoole protocol actively sets the FIN flag to 1 and ensures compression is not enabled (i.e., the RSV1 bit is 0). User settings for this will be ignored. - When handling compression and sending of consecutive frames, Swoole delegates the responsibility of compression and data chunking to the application layer. Users need to manually implement the relevant logic. See the example below for details. |
| 6.1.0RC1 |
## **Standard Library Extension** In version `6.1`, `Swoole-Cli` will introduce extended syntax for the `PHP` standard library, providing additional new syntax while maintaining full compatibility with the official `PHP` syntax. These new extended syntax features are entirely optional and do not affect existing `PHP` code. The standard library extension syntax will be implemented in the `stdext` module of `ext-swoole`. - `swoole-cli` users can use it directly without any additional parameters. - `ext-swoole` users need to add `--enable-swoole-stdext` during compilation to enable it. - `stdext` can be used in `php-cli`, `php-fpm`, `cli-http-server`, and `swoole` modes. ### **1. Object-Oriented Basic Types** Version `6.1` implements object-oriented encapsulation of basic types such as `array`, `string`, and `stream`, supporting method calls in an object-oriented style. Built-in methods can be directly called on variables of these types. The built-in methods for basic types still utilize the `PHP` standard library. These methods correspond one-to-one with `PHP`'s `str_` or `array_` series functions. For example, `$text->replace()` corresponds to the `str_replace` function. The underlying implementation only adjusts function names, slightly modifies the parameter order for a few methods, and adjusts parameter and return value types for several others. For details, please refer to the [Swoole Documentation](https://wiki.swoole.com/). ### **2. Typed-Array** Typed arrays can enforce type constraints, such as `Map` or `ArrayList`, and restrict the types of keys and values. Multi-level nested formats are supported. Typed arrays are still essentially `array` types, with parameter checks performed only during write operations. Typed arrays can be passed as `array` to other functions or class methods. ## **New Features** - **Default llHTTP Parser**: Starting from v6.1.0, Swoole uses the higher-performance `llhttp` as the default HTTP message parser, replacing `http_parser`. - **Coroutine-Based File Download**: `Swoole\Coroutine\Http\Client` now supports full coroutine-based file download operations. - **Asynchronous File Truncation**: Added support for `iouring ftruncate`, expanding asynchronous file operation capabilities. ## **Bug Fixes** - **Thread Mode Optimization**: - Fixed the issue where `hook_flags` settings were ineffective in `SWOOLE_THREAD` mode. - Fixed the issue where heartbeat threads held invalid pointers and accessed freed memory after worker threads restarted due to reaching the `max_request` limit. - Fixed the issue where `Task` processes could not be restarted individually. - **Stability Improvements**: - Fixed the issue where synchronous processes (including manager and task processes) could not use `process::signal()` properly. - Corrected the resource cleanup mechanism when worker processes exit abnormally. - Resolved compilation failures on the Cygwin platform. - Fixed the issue where curl could not reuse sockets when keepalive was enabled. - Improved the logging component to address data consistency issues in multi-threaded mode. - Fixed compilation failures of the `futex` feature in `io_uring` on `ubuntu24.04`. - Fixed compilation failures caused by struct sequential assignment on older Linux systems. - Fixed the issue where the `id` property of directly instantiated `Swoole\Process` objects was uninitialized. - Fixed the missing zstd option in composer.json when compiling Swoole with PIE. - **Compatibility Improvements**: - Fixed compatibility issues with `php_swoole_register_shutdown_function` on PHP 8.5. - Corrected the handling of null parameters in `Swoole\Table::get()`. - **Protocol Handling**: - Optimized the handling of duplicate fields in HTTP request and response headers to ensure proper merging. - Fixed the issue where a warning about an unknown compression method was triggered when processing client `Accept-Encoding: zlib` headers without `zlib` installed. ## Deprecations - Support for the `select` event mechanism has been removed. `select` only supports event monitoring for up to `1024` handles and has significant limitations. On platforms that do not support `epoll/kqueue`, `poll` will be used as the event polling mechanism, enabling support for high concurrency even on the `Cygwin` platform. - The second parameter `$waitEvent` in `Swoole\Server::stop()` has been deprecated. Please use the `reload_async` parameter instead. ## **Architectural Optimizations** Version `6.1` adds extensive unit tests for core modules, increasing test coverage to **86%**. By systematically supplementing test cases and refactoring underlying code logic, combined with full static code analysis using the `clang-tidy` toolchain, automated code formatting and redundancy cleanup have been achieved, significantly improving code readability and maintainability. - Optimized the underlying `SSL` module. - Optimized the underlying `Socket` module. - Refactored the underlying synchronous signal module. - Refactored the underlying `reactor` and `string` modules. - Refactored the underlying dynamic log file reloading mechanism based on `SIGRTMIN` signals. - Optimized the underlying static file server by removing C-style code and unifying it into C++-style code. - Optimized thread initialization logic to improve multi-threaded performance. Memory for independent management structures is now managed separately, eliminating the need for locks during thread creation and exit. - Removed the `socket_dontwait` option from the underlying `async` module, as it is deprecated. - Improved test coverage for `WebSocket` mask handling. - Optimized the `sendfile` functionality to avoid setting the `tcp_cork` option for files smaller than `64KB`. - Added unit tests for `aarch64` and `macOS` environments. - Optimized underlying client network address resolution and settings. - Added `ssl_cafile/ssl_capath` configuration items for the `Server` module. - Added the `print_backtrace_on_error` configuration, which prints C function stack traces when location errors occur. - Added the `Address Sanitizer` debugging tool. - Added `Cygwin` testing, significantly improving compatibility and stability on the `Cygwin` platform. - On `macOS` systems, the `kqueue` event mechanism does not support cross-process pipe event monitoring, making it impossible to use `SWOOLE_PROCESS` mode and `Task` processes. Therefore, the system defaults to using `poll` as the underlying event mechanism. To enable `kqueue`, manually activate it using `Swoole\Server::set(['enable_kqueue' => true])` and `swoole_async_set(['enable_kqueue' => true])`. ## **Note** - This version is an `RC` (Release Candidate) and not an official release. It is recommended for use only in testing environments and should not be used in production. ## **Acknowledgments** Sincere thanks to @matyhtf @jingjingxyk @sy-records @KIMDONGYEON00 @ServBayDev @NathanFreeman and all contributors for their professional efforts. Swoole is stronger because of you! Wishing all open-source community partners good health, success in all endeavors, and smooth work. |
| 6.0.2 |
- Added `Swoole\Thread::yield()`, `Swoole\Thread::activeCount()`, and `Swoole\Thread::isAlive()` methods. @matyhtf - Fixed an issue where using single-thread mode and setting heartbeat in `SWOOLE_THREAD` mode would cause exceptions. @matyhtf - Fixed a segmentation fault issue after enabling `swoole.enable_fiber_mock`. @NathanFreeman - Fixed an integer overflow issue in the Redis server. @yannaingtun - The Redis server currently only supports the `RESP2` protocol. When formatting strings that do not comply with this protocol, an exception will be thrown instead of logging. @matyhtf |