Home Cloud and DevOps Enterprise PHP Swoole PHP 4.6.3 Released with Multiple New Features and Enhancement

Swoole PHP 4.6.3 Released with Multiple New Features and Enhancement

swoole mascot

Swoole PHP v4.6.3 have just been released with multiple new features and enhancement today including set Content-Length header, compression_min_length and more…

Namespace alias functions are added for go and defer

Two new functions with namespace are added: Swoole\Coroutine\go and Swoole\Coroutine\go.

These functions can be used when you have disabled the short named functions godefer.

Example of Swoole\Coroutine\go and Swoole\Coroutine\go:


use function Swoole\Coroutine\go;
use function Swoole\Coroutine\run;
use function Swoole\Coroutine\defer;

run(function () {
    defer(function () {
        echo "co1\n";
    go(function () {
        echo "co2\n";


To specify the minimum length of the response to compress, use the compression_min_length directive. The default is 20 bytes.


$http->set(['compression_min_length' => 128]);

Content-Length header support

From Swoole PHP 4.6.3, you can set the Content-Length header if the content length is known or you like to change the default Content-Length header calculated by Swoole Server.


use Swoole\Http\Server;
use Swoole\Http\Request;
use Swoole\Http\Response;

$http = new Server('', 9000);

$http->on('Request', function (Request $request, Response $response) {
    $msg = 'Hello, Swoole';
    $response->header('Content-Length', 5);
    //$response->header('Content-Length', strlen($msg));


List of changes in Swoole PHP v4.6.3

New APIs
+ Added Swoole\Coroutine\go function (swoole/library@82f63be) (@matyhtf)
+ Added Swoole\Coroutine\defer function (swoole/library@92fd0de) (@matyhtf)

+ Added option compression_min_length for HTTP Server (#4033) (@matyhtf)
+ Allowed setting content-length HTTP header in application layer (#4041) (@doubaokun)

* Fixed coredump when program reach file open limitation (swoole/swoole-src@709813f) (@matyhtf)
* Fixed JIT being disabled (#4029) (@twose)
* Fixed Response::create() bug (swoole/swoole-src@a630b5b) (@matyhtf)
* Fixed task process id false positives on ARM (#4040) (@doubaokun)
* Fixed README (#4046) (@asheroto)
* Fixed native-curl crash on PHP8 (#4042) (#4045) (@Yurunsoft) (@matyhtf)
* Fixed mem error (#4050) (@matyhtf)

* Optimized ssl_connect/ssl_shutdown (#4030) (@matyhtf)
* Exit the process directly when a fatal error occurs (#4053) (@matyhtf)

You can upgrade to Swoole v4.6.3 now:

pecl install swoole

Swoole PHP is an event-driven asynchronous & coroutine-based concurrency networking communication engine with high performance written in C++ for PHP. Released under an Apache 2.0 License. More information at www.swoole.co.uk



Please enter your comment!
Please enter your name here