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
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.
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 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.
OpenSwoole can be installed with PIE, the PHP Installer for Extensions:
pie install openswoole/ext-openswoole
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.
stream_socket_enable_crypto() with TLS (#401)$server->getClientInfo() when the worker process ID is greater than 65535curl_copy_handle() not keeping the CURLOPT_STDERR stream and the callback data in the coroutine curl hookenable_reuse_port having no effect on Linux because SO_REUSEPORT was not detected at build timehttp2_* server settings being ignored and not sent to clients in the SETTINGS framemax_idle_time closing active connections and ignoring fractions of a secondcurl_copy_handle() or connection reuse in curl_multico::run() not returning for minutes after curl_multi requests in the coroutine curl hookSIGALRM when a timer was created before Server::start()HEAD requestsPING frames and its handling of GOAWAY and padded framesCurlHandle objects never being freed with CURLOPT_HEADERFUNCTION in the coroutine curl hook on PHP 8.4+ (#391)HEAD requests sending a bodyOpenSwoole\Table ignoring a conflictProportion below 1 (#362)reactor_type is accepted by Server::set() (#408)CONTINUATION frames, and HPACK errors when http2_header_table_size is set (#388)mysqli_init() and real_connect() in a coroutine (#378)max_request_execution_time ending later requests early and crashing workers (#315, #358)opcache.preload is enabled (#343)on('handshake') (#303)configure not finding libpq in lib64 without pg_config (#245)SIGPIPEuse_fiber_context, which crashed the worker when variables were inspected (#404)SWOOLE_PROCESS mode (#405)open_redis_protocol parser with commands split across reads and pipelined commandsOpenSwoole\Table keys longer than 63 bytes and row lockingCoroutine::select() with push channels and array keysLock::lockwait() truncating the timeout, and process pipes never being closedIf 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
Join 4,000+ others and never miss out on new tips, tutorials, and more.