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.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 |
6.0.1 | 2025-02-14 | swoole-6.0.1.tgz |
6.0.0 | 2024-12-16 | swoole-6.0.0.tgz |
Version | Message |
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 |
6.0.1 |
- Fixed an issue in `SWOOLE_THREAD` mode where the process could not exit properly due to not removing the listening event. @NathanFreeman - Fixed an issue where large file uploads failed when the `single_thread` configuration was enabled. @matyhtf - Fixed an issue where compilation could not find the specific file path if the same variable was already defined in `config.m4`. @matyhtf - Fixed an issue in `Swoole\Process\Pool` where processes could not exit properly upon timeout. @matyhtf - Fixed an issue in `SWOOLE_THREAD` mode where calling `putenv` caused the program to crash. @matyhtf - Fixed an issue in `SWOOLE_THREAD` mode where event callback functions could not be set for independent ports. @matyhtf - Fixed an issue in `SWOOLE_THREAD` mode where runtime parameters could not be retrieved in events such as `onWorkerStart`. @matyhtf - Fixed an issue where Postgresql would degrade to synchronous mode when receiving large amounts of data under coroutine. @NathanFreeman - Optimized the parameter judgment logic of `swoole_substr_json_decode`/`swoole_substr_unserialize` functions. @Appla - Fixed an issue with CPU affinity settings in `config.m4`. @remicollet - In the Http service, if the process restarts, the underlying layer will send a 500 Internal Server to requests waiting in the queue, close the connection, and discard these requests after sending. @NathanFreeman - Since the runtime configuration relied upon by the `stream factory` and `stream ops` in the PHP underlying is not thread-safe, in multi-thread mode, only the main thread is allowed to modify these runtime configurations before creating child threads. @matyhtf - Fixed an issue in `SWOOLE_THREAD` mode where the heartbeat detection did not function properly. @matyhtf |
6.0.0 |
- Added multi-threading support, require the ZTS version of PHP. Add `--enable-swoole-thread` option to the configure command to activate it. - Added a new thread class `Swoole\Thread`. @matyhtf - Introduced thread lock `Swoole\Thread\Lock`. @matyhtf - Added thread atomic counter `Swoole\Thread\Atomic`, `Swoole\Thread\Atomic\Long`. @matyhtf - Added safe concurrent containers `Swoole\Thread\Map`, `Swoole\Thread\ArrayList`, `Swoole\Thread\Queue`. @matyhtf - The file asynchronous operation supports using `io_uring` as the underlying engine for file asynchronous operations. When liburing is installed and Swoole is compiled with the --enable-iouring option, the asynchronous operations of functions such as file_get_contents, file_put_contents, fopen, fclose, fread, fwrite, mkdir, unlink, fsync, fdatasync, rename, fstat, lstat, and filesize will be implemented by io_uring. @matyhtf @NathanFreeman - Upgraded `Boost Context` to version 1.84. Now, Loongson CPUs can also support coroutines. @NathanFreeman - Added `Swoole\Thread\Map::find()` method. @matyhtf - Added `Swoole\Thread\ArrayList::find()` method. @matyhtf - Added `Swoole\Thread\ArrayList::offsetUnset()` method. @matyhtf - Added `Swoole\Process::getAffinity()` method. @matyhtf - Added `Swoole\Thread::setName()` method. @matyhtf - Added `Swoole\Thread::setAffinity()` method. @matyhtf - Added `Swoole\Thread::getAffinity()` method. @matyhtf - Added `Swoole\Thread::setPriority()` method. @matyhtf - Added `Swoole\Thread::getPriority()` method. @matyhtf - Added `Swoole\Thread::gettid()` method. - The file asynchronous engine `iouring` supports multi-threaded polling mode `IORING_SETUP_SQPOLL`. @NathanFreeman - Added `iouring_workers` to modify the number of `iouring` threads. @NathanFreeman - Added `iouring_flags` to support modifying the `iouring` working mode. @NathanFreeman - Added `Swoole\Thread\Barrier` for multi-thread synchronization barrier. @matyhtf - Added new function and class to set cookies. @matyhtf @NathanFreeman - Added `non-blocking, reentrant coroutine mutex lock`, which can be used between processes/threads without blocking them. @NathanFreeman - `Swoole\Coroutine\Socket::getOption()` supports the `TCP_INFO` option. @matyhtf - `Swoole\Client` synchronous blocking client supports `http` proxy. @matyhtf - Added asynchronous non-blocking `TCP/UDP/Unix socket` client `Swoole\Async\Client`. @matyhtf - Optimized the `Swoole\Redis\Server::format()` method to support zero-copy memory, support `redis` nested structure. @matyhtf - Supports the high-performance compression tool `Zstd`. You only need to add `--enable-zstd` when compiling `Swoole`, and then `zstd` can be used to compress or decode responses between the `http` client and server. @NathanFreeman - Fixed the issue where installation via `pecl` was not possible. @remicollet - Fixed the bug where setting `keepalive` was not possible for `Swoole\Coroutine\FastCGI\Client`. @NathanFreeman - Fixed the issue where exceeding the `max_input_vars` would throw an error, causing the process to restart repeatedly. @NathanFreeman - Fixed unknown issues caused by using `Swoole\Event::wait()` within a coroutine. @matyhtf - Fixed the problem where `proc_open` does not support pty in coroutine mode. @matyhtf - Fixed segmentation fault issues with `pdo_sqlite` on PHP 8.3. @NathanFreeman - Fixed unnecessary warnings during the compilation of `Swoole`. @Appla @NathanFreeward - Fixed the error thrown by zend_fetch_resource2_ex when `STDOUT/STDERR` are already closed. @Appla @matyhtf - Fixed ineffective `set_tcp_nodelay` configuration. @matyhtf - Fixed the occasional unreachable branch issue during file upload. @NathanFreeman - Fixed the problem where setting `dispatch_func` would cause PHP's internals to throw errors. @NathanFreeman - Fixed the deprecation of AC_PROG_CC_C99 in autoconf >= 2.70. @petk - Capture exceptions when thread creation fails. @matyhtf - Fixed the undefined problem with `_tsrm_ls_cache`. @jingjingxyk - Fixed the fatal compile error with `GCC 14`. @remicollet - Fixed the dynamic property issue in `Swoole\Http2\Request`. @guandeng - Fixed the occasional resource unavailability issue in the `pgsql` coroutine client. @NathanFreeman - Fixed the issue of 503 errors due to not resetting related parameters during process restart. @matyhtf - Fixed the inconsistency between `$request->server['request_method']` and `$request->getMethod()` when `HTTP2` is enabled. @matyhtf - Fixed incorrect `content-type` when uploading files. @matyhtf - Fixed code errors in the `http2` coroutine client. @matyhtf - Fixed the missing `worker_id` property in `Swoole\Server`. @cjavad - Fixed errors related to `brotli` in `config.m4`. @fundawang - Fixed the invalid `Swoole\Http\Response::create` under multi-threading. @matyhtf - Fixed compilation errors in the `macos` environment. @matyhtf - Fixed the issue of threads not being able to exit safely. @matyhtf - Fixed the issue where the static variable for response time returned by `Swoole\Http\Response` in multi-threaded mode was not generated separately for each thread. @matyhtf @NathanFreeman - Fixed `Fatal error` issue caused by `PHP-8.4`'s `timeout` feature in ZTS mode. @matyhtf - Fixed compatibility issue with the `exit()` `hook` function for `PHP-8.4`. @remicollet - Fixed the issue where `Swoole\Thread::getNativeId()` did not work in `cygwin`. @matyhtf - Fixed the issue causing `SIGSEGV` in `Swoole\Coroutine::getaddrinfo()` method. @matyhtf - Fixed the issue where the runtime TCP module did not support dynamically enabling SSL encryption. @matyhtf - Fixed the issue where the HTTP client had an incorrect timeout after running for a long time. @matyhtf - Fixed the problem where the mutex lock of `Swoole\Table` could not be used before the process exited. @matyhtf - Fixed the failure of `Swoole\Server::stop()` when using named parameters. @matyhtf - Fixed the crash caused by `Swoole\Thread\Map::toArray()` not copying the key. @matyhtf - Fixed the issue of being unable to delete nested numeric keys in `Swoole\Thread\Map`. @matyhtf - Removed unnecessary checks for `socket structs`. @petk - Upgraded Swoole Library. @deminy - Added support for status code 451 in `Swoole\Http\Response`. @abnegate - Synchronized `file` operation code across different PHP versions. @NathanFreeman - Synchronized `pdo` operation code across different PHP versions. @NathanFreeman - Optimized the code for `Socket::ssl_recv()`. @matyhtf - Improved config.m4; some configurations can now set library locations via `pkg-config`. @NathanFreeman - Optimized the use of dynamic arrays during `request header parsing`. @NathanFreeman - Optimized file descriptor `fd` lifecycle issues in multi-threading mode. @matyhtf - Optimized some fundamental coroutine logic. @matyhtf - Upgraded the Oracle database version for CI testing. @gvenzl - Optimized the underlying logic of `sendfile`. @matyhtf - Replaced `PHP_DEF_HAVE` with `AC_DEFINE_UNQUOTED` in `config.m4`. @petk - Optimized the logic related to `heartbeat`, `shutdown`, and `stop` for the server in multi-threaded mode. @matyhtf - Optimized to avoid linking `librt` when `glibc` version is greater than 2.17. @matyhtf - Enhanced the HTTP client to accept duplicate request headers. @matyhtf - Optimized `Swoole\Http\Response::write()`. @matyhtf - `Swoole\Http\Response::write()` can now send HTTP/2 protocol. @matyhtf - Compatible with `PHP 8.4`. @matyhtf @NathanFreeman - Added the ability for asynchronous writing at the underlying socket level. @matyhtf - Optimized `Swoole\Http\Response`. @NathanFreeman - Improved underlying error messages. @matyhtf - Supported sharing PHP native sockets in multi-threaded mode. @matyhtf - Optimized static file service and fixed static file path error issues. @matyhtf - Multi-thread mode `SWOOLE_THREAD` supports restarting worker threads. @matyhtf - Multi-thread mode `SWOOLE_THREAD` supports starting timers in the `Manager` thread. @matyhtf - Compatible with the `curl` extension of `PHP-8.4`. @matyhtf @NathanFreeman - Rewrite the underlying `Swoole` code using `iouring`. @matyhtf @NathanFreeman - Optimized timers so that synchronous processes do not depend on signals. @matyhtf - Optimized the `Swoole\Coroutine\System::waitSignal()` method to allow listening to multiple signals simultaneously. @matyhtf - No longer supports `PHP 8.0`. - No longer supports `Swoole\Coroutine\MySQL` coroutine client. - No longer supports `Swoole\Coroutine\Redis` coroutine client. - No longer supports `Swoole\Coroutine\PostgreSQL` coroutine client. - Removed `Swoole\Coroutine\System::fread()`, `Swoole\Coroutine\System::fwrite()`, and `Swoole\Coroutine\System::fgets()` methods. |