OpenSwoole 22.0.0 released for PHP 8.2 and Psr, GRPC

Published:

OpenSwoole 22.0.0 is a major release including new features such as Psr support, GRPC support and performance improvement.

Official OpenSwoole version 22.0.0Official OpenSwoole version 22.0.0

GRPC support

Open Swoole GRPC for PHP version 2022 is a high-performance integration solution for building cloud-native multiple language microservices architecture.

You can find more details at https://openswoole.com/article/openswoole-grpc.

Psr support

Psr (PHP Standards Recommendations) is the community effort of moving PHP forward through collaboration and standards. To better support the community standards, OpenSwoole Psr is a part of OpenSwoole Core since v22 (version 2022).

You have to install OpenSwoole Core library with composer require openswoole\core to use this feature.

You can find more details at https://openswoole.com/docs/psr

OpenSwoole Core library

You have to install composer core libraries to get all the features:

composer require openswoole/core

Examples

If you are new to openswoole v22, you can find the examples at the openswoole/example repo:

composer create-project openswoole/example

cd example

# HTTP Psr
php src/Psr/PsrHandle.php
php src/Psr/PsrRoute.php
php src/Psr/PsrSetHandler.php

# Other examples

Changelog

 . Rename `co\run` to be `co::run`
 . Security update: Remove embedded PHP codes, hot code execution with eval and remove `ini` option `enable_library`
 . Added server Constants class: OpenSwoole\Constant
 . Use \OpenSwoole as the main namespace, although \Swoole is still supported
 . Pre-check server options
 . Security update: New server option `enable_server_token`, disabled by default
 . Built-in Psr7 API support added
 . Boost ASM library upgrade
 . New Psr API: $server->setHandler(\Psr\Http\Server\RequestHandlerInterface $handler)
 . New Psr API: $server->handle(callable $callback)
 . Redis Server API: $server->setHandler() -> $server->addCommand()
 . Redis Server API: $server->getHandler() -> $server->getCommand()
 . Disable sockets_*, exec, shell_exec, `gethostbyname` coroutines hook by default, remove HOOK_BLOCKING_FUNCTION and HOOK_SOCKETS in HOOK_ALL; Enable them explicitly if they are used
 . Remove deprecated custom coroutine MySQL client, prefer the hooked native coroutine MySQL client
 . Remove deprecated custom coroutine Redis client, prefer the hooked native coroutine Redis client
 . Remove deprecated experimental coroutine HTTP server
 . Remove deprecated experimental Redis protocol server
 . Remove deprecated function `swoole_timer_set()` and `Timer->set()`
 . Remove deprecated function `swoole_event_rshutdown`
 . Remove deprecated function `Swoole\Runtime::fread`, `Swoole\Runtime::fwrite`, `Swoole\Runtime::fgets`
 . Remove deprecated function `Coroutine::suspend`, use `Coroutine::yield`
 . Remove deprecated function `Coroutine::getuid`, use `Coroutine::getCid`
 . Remove deprecated function `Coroutine::listCoroutines`, use `Coroutine::list`
 . Remove deprecated function `Table::exist`, use `Table::exists`
 . Remove deprecated function `Table::delete`, use `Table::del`
 . Remove deprecated function `Server->connection_info()`, use `Server->getClientInfo()`
 . Remove deprecated function `Server->connection_list()`, use `Server->getClientList()`
 . Remove deprecated function `Server->exist`, use `Server->exists`
 . Move global constants under namespace: SWOOLE_CHANNEL_OK -> `OpenSwoole\Coroutine\Channel::CHANNEL_OK`, SWOOLE_CHANNEL_TIMEOUT -> `OpenSwoole\Coroutine\Channel::CHANNEL_TIMEOUT`, SWOOLE_CHANNEL_CLOSED -> `OpenSwoole\Coroutine\Channel::CHANNEL_CLOSED`...
 . Move global constants under namespace: SWOOLE_DEFAULT_MAX_CORO_NUM -> `OpenSwoole\Coroutine::DEFAULT_MAX_CORO_NUM`...
 . Remove `$server->getLastError()`, use `OpenSwoole\Util::getLastErrorCode()`
 . Remove `$process->name()`, use `OpenSwoole\Util::setProcessName()`
 . New Util API class: added `OpenSwoole\Util` class
 . Remove option `swoole.use_shortname`, remove `Co\*` alias. `go`, `chan`, `defer`, `co::*` are available by default
 . Remove `swoole_async_dns_lookup_coro`, use `OpenSwoole\Coroutine::dnsLookup` or `OpenSwoole\Coroutine\System::dnsLookup`; remove `swoole_async_set`, use `OpenSwoole\Until::setAio([])` or `$server->set([])` for `aio` options;
 . Rename PHP `ini` options from `swoole.*` to be `openswoole.*`
 . Remove `swoole_clear_dns_cache`, use OpenSwoole\Coroutine::clearDNSCache` or `OpenSwoole\Coroutine\System::clearDNSCache`
 . Remove custom unserialize functions: `swoole_substr_unserialize` and `swoole_substr_unserialize`
 . Remove `swoole_client_select` and `swoole_select`, use `OpenSwoole\Client::select`
 . Remove `swoole_last_error`, use `OpenSwoole\Util::getLastErrorCode`
 . `OpenSwoole\Event::wait();` should be added explicitly to wait for all the IO events
 . Use `\OpenSwoole\Server::SIMPLE_MODE` and `\OpenSwoole\Server::POOL_MODE` at server structure config
 . Fix: ignore user set illegal HTTP header at server
 . Fix: ignore user set encoding header at client if it is not supported
 . Remove hard requirements and links of json and remove compile flag `--enable-swoole-json`
 . Rename compile flag `--enable-swoole-curl` to be `--enable-hook-curl`
 . Fix convert double sec to long microseconds in hooked usleep by @shandyDev

Thanks to the OpenSwoole Community Contributors

You can upgrade to OpenSwoole v22.0.0 now:

pecl install openswoole-22.0.0