OpenSwoole 26.11.0 released with PHP 8.6 support

OpenSwoole 26.11.0 adds support for PHP 8.6, extends the coroutine curl hook with the new PHP 8.6 seek callback, and fixes several bugs in the curl hook and the server.

You can upgrade to OpenSwoole v26.11.0 now:

pecl install openswoole-26.11.0

Or use Docker images:

docker pull openswoole/openswoole:26.11-php8.6-alpine

Find more OpenSwoole docker images at OpenSwoole Docker images at Docker Hub

New Features

PHP 8.6 Support

OpenSwoole 26.11.0 is compatible with PHP 8.6. It builds against the new PHP 8.6 internal APIs and is tested on PHP 8.3, 8.4, 8.5 and 8.6. PHP 8.6.0 is not released yet: OpenSwoole 26.11.0 is tested with PHP 8.6.0RC7, and the PHP 8.6 Docker images are built on the release candidate until PHP 8.6.0 is out.

CURLOPT_SEEKFUNCTION in the Coroutine curl Hook

PHP 8.6 adds CURLOPT_SEEKFUNCTION, which lets libcurl rewind an upload stream, for example when it has to resend a request body after a redirect or an authentication challenge. The callback now works with SWOOLE_HOOK_NATIVE_CURL too:

use OpenSwoole\Runtime;

Runtime::enableCoroutine(Runtime::HOOK_ALL);

co::run(function () {
    $body = str_repeat('x', 4096);
    $pos = 0;

    $ch = curl_init('https://example.com/upload');
    curl_setopt_array($ch, [
        CURLOPT_UPLOAD => true,
        CURLOPT_INFILESIZE => strlen($body),
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_READFUNCTION => function ($ch, $fp, $length) use (&$pos, $body) {
            $chunk = substr($body, $pos, $length);
            $pos += strlen($chunk);
            return $chunk;
        },
        CURLOPT_SEEKFUNCTION => function ($ch, $offset, $origin) use (&$pos) {
            $pos = $offset;
            return CURL_SEEKFUNC_OK;
        },
    ]);
    curl_exec($ch);
});

CURLOPT_PREREQFUNCTION in the Coroutine curl Hook

CURLOPT_PREREQFUNCTION is now supported by the coroutine curl hook on PHP 8.4 and later. Guzzle 7.12 and later use it, so recent Guzzle versions work with SWOOLE_HOOK_NATIVE_CURL again.

PIE Installation

OpenSwoole can be installed with PIE, the PHP Installer for Extensions:

pie install openswoole/ext-openswoole

Changes

Hooked ssl:// and tls:// client streams follow the ssl stream context options the same way as native PHP. To connect to a server with a self-signed certificate, set verify_peer to false:

$context = stream_context_create(['ssl' => ['verify_peer' => false, 'verify_peer_name' => false]]);
$fp = stream_socket_client('ssl://127.0.0.1:9501', $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $context);

Response::cookie() now also sends Max-Age when an expiry time is set, like PHP's setcookie() (#310).

Cookie values are now encoded and decoded the same way as PHP: a + stays a +, and a space is sent as %20. This applies to $request->cookie, Response::cookie() and the coroutine HTTP clients. Cookies containing spaces that were set by an earlier OpenSwoole version read back with + until they are set again. When a cookie name is sent twice, the first value is used, as in PHP-FPM (#311).

OpenSwoole 26.11 is the last release series to support PHP 8.3. OpenSwoole 27.2 will require PHP 8.4 or later.

Bug Fixes

  • Fix stream_socket_enable_crypto() with TLS (#401)
  • Fix the io_uring build on Alpine Linux (#400)
  • Fix the SSL client certificate missing from $server->getClientInfo() when the worker process ID is greater than 65535
  • Fix curl_copy_handle() not keeping the CURLOPT_STDERR stream and the callback data in the coroutine curl hook
  • Fix a crash in the coroutine curl hook when a curl multi handle is released after the event loop has been destroyed
  • Fix a crash in the preemptive scheduler
  • Fix enable_reuse_port having no effect on Linux because SO_REUSEPORT was not detected at build time
  • Fix the http2_* server settings being ignored and not sent to clients in the SETTINGS frame
  • Fix max_idle_time closing active connections and ignoring fractions of a second
  • Fix a crash when a coroutine is canceled during file I/O
  • Fix a crash in the coroutine curl hook with curl_copy_handle() or connection reuse in curl_multi
  • Fix co::run() not returning for minutes after curl_multi requests in the coroutine curl hook
  • Fix io_uring warnings logged on every file operation when io_uring is not available, for example in Docker containers with the default seccomp profile
  • Fix the server master process being killed by SIGALRM when a timer was created before Server::start()
  • Fix the static handler sending the file body for HEAD requests
  • Fix the HTTP/2 client reply to PING frames and its handling of GOAWAY and padded frames
  • Fix CurlHandle objects never being freed with CURLOPT_HEADERFUNCTION in the coroutine curl hook on PHP 8.4+ (#391)
  • Fix HTTP/2 server responses to HEAD requests sending a body
  • Fix bundled hiredis symbols colliding with other extensions that link hiredis (#394)
  • Fix the build on FreeBSD 14 and 15 (#389)
  • Fix OpenSwoole\Table ignoring a conflictProportion below 1 (#362)
  • Fix the io_uring reactor failing to start when io_uring is not available; it now falls back to epoll, and reactor_type is accepted by Server::set() (#408)
  • Fix HTTP/2 requests with headers split into CONTINUATION frames, and HPACK errors when http2_header_table_size is set (#388)
  • Fix a crash when closing a mysqli connection opened with mysqli_init() and real_connect() in a coroutine (#378)
  • Fix max_request_execution_time ending later requests early and crashing workers (#315, #358)
  • Fix coroutines crashing when opcache.preload is enabled (#343)
  • Fix the deprecation warning for on('handshake') (#303)
  • Fix configure not finding libpq in lib64 without pg_config (#245)
  • Fix task workers logging a warning for SIGPIPE
  • Fix Xdebug not seeing the request callback with use_fiber_context, which crashed the worker when variables were inspected (#404)
  • Fix the io_uring reactor not answering requests in SWOOLE_PROCESS mode (#405)
  • Fix the io_uring reactor on kernels before 5.13, where multishot poll is not available
  • Fix an HTTP/2 stream reset leaving a coroutine waiting
  • Fix the open_redis_protocol parser with commands split across reads and pipelined commands
  • Fix OpenSwoole\Table keys longer than 63 bytes and row locking
  • Fix Coroutine::select() with push channels and array keys
  • Fix Lock::lockwait() truncating the timeout, and process pipes never being closed
  • Various stability fixes

Upgrade

If you need to install OpenSwoole or look at other update methods, checkout the installation documentation and how to update Open Swoole.

Install the core library:

composer require openswoole/core:26.11.0