PHPackages                             swoole/swoole - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. swoole/swoole

ActivePhp-ext[HTTP &amp; Networking](/categories/http)

swoole/swoole
=============

Swoole is an event-driven, asynchronous, coroutine-based concurrency library with high performance for PHP.

v6.2.0(2mo ago)18.9k8.7k↓10.9%3.2k[6 PRs](https://github.com/swoole/swoole-src/pulls)1Apache-2.0C++PHP &gt;=8.2 &lt;8.6CI passing

Since Oct 17Pushed 1mo ago801 watchersCompare

[ Source](https://github.com/swoole/swoole-src)[ Packagist](https://packagist.org/packages/swoole/swoole)[ RSS](/packages/swoole-swoole/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (27)Used By (1)

[![Swoole Logo](docs/swoole-logo.svg)](docs/swoole-logo.svg)
 Swoole is an event-driven, asynchronous, coroutine-based concurrency library with high performance for PHP.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#-----swoole-is-an-event-driven-asynchronous-coroutine-based-concurrency-library-with-high-performance-for-php)

[![Compiler Tests](https://github.com/swoole/swoole-src/actions/workflows/ext.yml/badge.svg)](https://github.com/swoole/swoole-src/actions/workflows/ext.yml)[![Core Test](https://github.com/swoole/swoole-src/actions/workflows/core.yml/badge.svg)](https://github.com/swoole/swoole-src/actions/workflows/core.yml)[![Unit Tests](https://github.com/swoole/swoole-src/actions/workflows/unit.yml/badge.svg)](https://github.com/swoole/swoole-src/actions/workflows/unit.yml)[![Thread Support Tests](https://github.com/swoole/swoole-src/actions/workflows/thread.yml/badge.svg)](https://github.com/swoole/swoole-src/actions/workflows/thread.yml)[![Linux io_uring Tests](https://github.com/swoole/swoole-src/actions/workflows/iouring.yml/badge.svg)](https://github.com/swoole/swoole-src/actions/workflows/iouring.yml)[![Frameworks Tests](https://github.com/swoole/swoole-src/actions/workflows/framework.yml/badge.svg)](https://github.com/swoole/swoole-src/actions/workflows/framework.yml)

[![Twitter](https://camo.githubusercontent.com/938a48bafad518c277315ee27ebefa0a0ca9f7cde918eef1820810964ff6e9f5/68747470733a2f2f62616467656e2e6e65742f62616467652f69636f6e2f747769747465723f69636f6e3d74776974746572266c6162656c)](https://twitter.com/phpswoole)[![Discord](https://camo.githubusercontent.com/155081771f1f717ebd6be59f0cb88fb4ac65ee4a70fec13715509f7e280fdd50/68747470733a2f2f62616467656e2e6e65742f62616467652f69636f6e2f646973636f72643f69636f6e3d646973636f7264266c6162656c)](https://discord.swoole.dev)[![Latest Release](https://camo.githubusercontent.com/6eb5e0d993d7d3dd5a8bddac62bb1c50160336d056373d9c41c33471d7c6ac26/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73776f6f6c652f73776f6f6c652d7372632e737667)](https://github.com/swoole/swoole-src/releases/)[![License](https://camo.githubusercontent.com/0f8813a2501827c8942f851dfe1cf5bc44b8e658a4d252c9a987d3c5a0ecfc3b/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f73776f6f6c652f73776f6f6c652d737263)](https://github.com/swoole/swoole-src/blob/master/LICENSE)[![Coverity Scan Build Status](https://camo.githubusercontent.com/f7772076d721dd4d92e9c1e10bbad9159427e76b109c0c127b8ae77f24c48170/68747470733a2f2f7363616e2e636f7665726974792e636f6d2f70726f6a656374732f31313635342f62616467652e737667)](https://scan.coverity.com/projects/swoole-swoole-src)[![Codecov](https://camo.githubusercontent.com/0cdec60115358173cf5bc6be3b3b5fb11fb555993079e49fdeddff6cbaabf829/68747470733a2f2f636f6465636f762e696f2f67682f73776f6f6c652f73776f6f6c652d7372632f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/swoole/swoole-src)

⚙️ Quick Start
--------------

[](#️-quick-start)

Run Swoole program by [Docker](https://github.com/swoole/docker-swoole)

```
docker run --rm phpswoole/swoole "php --ri swoole"
```

> For details on how to use it, see: [How to Use This Image](https://github.com/swoole/docker-swoole#how-to-use-this-image).

Documentation
-------------

[](#documentation)

### HTTP Service

[](#http-service)

```
$http = new Swoole\Http\Server('127.0.0.1', 9501);
$http->set(['hook_flags' => SWOOLE_HOOK_ALL]);

$http->on('request', function ($request, $response) {
    $result = [];
    Co::join([
        go(function () use (&$result) {
            $result['google'] = file_get_contents("https://www.google.com/");
        }),
        go(function () use (&$result) {
            $result['taobao'] = file_get_contents("https://www.taobao.com/");
        })
    ]);
    $response->end(json_encode($result));
});

$http->start();
```

### Concurrency

[](#concurrency)

```
Co\run(function() {
    Co\go(function() {
        while(1) {
            sleep(1);
            $fp = stream_socket_client("tcp://127.0.0.1:8000", $errno, $errstr, 30);
            echo fread($fp, 8192), PHP_EOL;
        }
    });

    Co\go(function() {
        $fp = stream_socket_server("tcp://0.0.0.0:8000", $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN);
        while(1) {
            $conn = stream_socket_accept($fp);
            fwrite($conn, 'The local time is ' . date('n/j/Y g:i a'));
        }
    });

    Co\go(function() {
        $redis = new Redis();
        $redis->connect('127.0.0.1', 6379);
        while(true) {
            $redis->subscribe(['test'], function ($instance, $channelName, $message) {
                echo 'New redis message: '.$channelName, "==>", $message, PHP_EOL;
            });
        }
    });

    Co\go(function() {
        $redis = new Redis();
        $redis->connect('127.0.0.1', 6379);
        $count = 0;
        while(true) {
            sleep(2);
            $redis->publish('test','hello, world, count='.$count++);
        }
    });
});
```

Runtime Hook
------------

[](#runtime-hook)

**Swoole hooks the blocking io function of PHP at the `bottom layer` and `automatically` converts it to a non-blocking function, so that these functions can be called concurrently in coroutines.**

### Supported extension/functions

[](#supported-extensionfunctions)

- `ext-curl` (Support `symfony` and `guzzle`)
- `ext-redis`
- `ext-mysqli`
- `ext-pdo_mysql`
- `ext-pdo_pgsql`
- `ext-pdo_sqlite`
- `ext-pdo_oracle`
- `ext-pdo_odbc`
- `stream functions` (e.g. `stream_socket_client`/`stream_socket_server`), Supports `TCP`/`UDP`/`UDG`/`Unix`/`SSL/TLS`/`FileSystem API`/`Pipe`
- `ext-sockets`
- `ext-soap`
- `sleep`/`usleep`/`time_sleep_until`
- `proc_open`
- `gethostbyname`/`shell_exec`/`exec`
- `fread`/`fopen`/`fsockopen`/`fwrite`/`flock`

🛠 Develop &amp; Discussion
--------------------------

[](#-develop--discussion)

- **IDE Helper &amp; API**:
- **Twitter**:
- **Discord**:
- **中文社区**:

💎 Awesome Swoole
----------------

[](#-awesome-swoole)

Project [Awesome Swoole](https://github.com/swoole/awesome-swoole) maintains a curated list of awesome things related to Swoole, including

- Swoole-based frameworks and libraries.
- Packages to integrate Swoole with popular PHP frameworks, including Laravel, Symfony, Slim, and Yii.
- Books, videos, and other learning materials about Swoole.
- Debugging, profiling, and testing tools for developing Swoole-based applications.
- Coroutine-friendly packages and libraries.
- Other Swoole related projects and resources.

✨ Event-based
-------------

[](#-event-based)

The network layer in Swoole is event-based and takes full advantage of the underlying epoll/kqueue implementation, making it really easy to serve millions of requests.

Swoole 4.x uses a brand new engine kernel and now it has a full-time developer team, so we are entering an unprecedented period in PHP history which offers a unique possibility for rapid evolution in performance.

⚡ Coroutine
-----------

[](#-coroutine)

Swoole 4.x or later supports the built-in coroutine with high availability, and you can use fully synchronized code to implement asynchronous performance. PHP code without any additional keywords, the underlying automatic coroutine-scheduling.

Developers can understand coroutines as ultra-lightweight threads, and you can easily create thousands of coroutines in a single process.

### MySQL

[](#mysql)

Concurrency 10K requests to read data from MySQL takes only 0.2s!

```
$s = microtime(true);
Co\run(function() {
    for ($c = 100; $c--;) {
        go(function () {
            $mysql = new Swoole\Coroutine\MySQL;
            $mysql->connect([
                'host' => '127.0.0.1',
                'user' => 'root',
                'password' => 'root',
                'database' => 'test'
            ]);
            $statement = $mysql->prepare('SELECT * FROM `user`');
            for ($n = 100; $n--;) {
                $result = $statement->execute();
                assert(count($result) > 0);
            }
        });
    }
});
echo 'use ' . (microtime(true) - $s) . ' s';
```

### Mixed server

[](#mixed-server)

You can create multiple services on the single event loop: TCP, HTTP, Websocket and HTTP2, and easily handle thousands of requests.

```
function tcp_pack(string $data): string
{
    return pack('N', strlen($data)) . $data;
}
function tcp_unpack(string $data): string
{
    return substr($data, 4, unpack('N', substr($data, 0, 4))[1]);
}
$tcp_options = [
    'open_length_check' => true,
    'package_length_type' => 'N',
    'package_length_offset' => 0,
    'package_body_offset' => 4
];
```

```
$server = new Swoole\WebSocket\Server('127.0.0.1', 9501, SWOOLE_BASE);
$server->set(['open_http2_protocol' => true]);
// http && http2
$server->on('request', function (Swoole\Http\Request $request, Swoole\Http\Response $response) {
    $response->end('Hello ' . $request->rawcontent());
});
// websocket
$server->on('message', function (Swoole\WebSocket\Server $server, Swoole\WebSocket\Frame $frame) {
    $server->push($frame->fd, 'Hello ' . $frame->data);
});
// tcp
$tcp_server = $server->listen('127.0.0.1', 9502, SWOOLE_TCP);
$tcp_server->set($tcp_options);
$tcp_server->on('receive', function (Swoole\Server $server, int $fd, int $reactor_id, string $data) {
    $server->send($fd, tcp_pack('Hello ' . tcp_unpack($data)));
});
$server->start();
```

### Coroutine clients

[](#coroutine-clients)

Whether you DNS query or send requests or receive responses, all of these are scheduled by coroutine automatically.

```
go(function () {
    // http
    $http_client = new Swoole\Coroutine\Http\Client('127.0.0.1', 9501);
    assert($http_client->post('/', 'Swoole Http'));
    var_dump($http_client->body);
    // websocket
    $http_client->upgrade('/');
    $http_client->push('Swoole Websocket');
    var_dump($http_client->recv()->data);
});
go(function () {
    // http2
    $http2_client = new Swoole\Coroutine\Http2\Client('localhost', 9501);
    $http2_client->connect();
    $http2_request = new Swoole\Http2\Request;
    $http2_request->method = 'POST';
    $http2_request->data = 'Swoole Http2';
    $http2_client->send($http2_request);
    $http2_response = $http2_client->recv();
    var_dump($http2_response->data);
});
go(function () use ($tcp_options) {
    // tcp
    $tcp_client = new Swoole\Coroutine\Client(SWOOLE_TCP);
    $tcp_client->set($tcp_options);
    $tcp_client->connect('127.0.0.1', 9502);
    $tcp_client->send(tcp_pack('Swoole Tcp'));
    var_dump(tcp_unpack($tcp_client->recv()));
});
```

### Channel

[](#channel)

Channel is the only way for exchanging data between coroutines, the development combination of the `Coroutine + Channel` is the famous CSP programming model.

In Swoole development, Channel is usually used for implementing connection pool or scheduling coroutine concurrent.

#### The simplest example of a connection pool

[](#the-simplest-example-of-a-connection-pool)

In the following example, we have a thousand concurrently requests to redis. Normally, this has exceeded the maximum number of Redis connections setting and will throw a connection exception, but the connection pool based on Channel can perfectly schedule requests. We don't have to worry about connection overload.

```
class RedisPool
{
    /**@var \Swoole\Coroutine\Channel */
    protected $pool;

    /**
     * RedisPool constructor.
     * @param int $size max connections
     */
    public function __construct(int $size = 100)
    {
        $this->pool = new \Swoole\Coroutine\Channel($size);
        for ($i = 0; $i < $size; $i++) {
            $redis = new \Swoole\Coroutine\Redis();
            $res = $redis->connect('127.0.0.1', 6379);
            if ($res == false) {
                throw new \RuntimeException("failed to connect redis server.");
            } else {
                $this->put($redis);
            }
        }
    }

    public function get(): \Swoole\Coroutine\Redis
    {
        return $this->pool->pop();
    }

    public function put(\Swoole\Coroutine\Redis $redis)
    {
        $this->pool->push($redis);
    }

    public function close(): void
    {
        $this->pool->close();
        $this->pool = null;
    }
}

go(function () {
    $pool = new RedisPool();
    // max concurrency num is more than max connections
    // but it's no problem, channel will help you with scheduling
    for ($c = 0; $c < 1000; $c++) {
        go(function () use ($pool, $c) {
            for ($n = 0; $n < 100; $n++) {
                $redis = $pool->get();
                assert($redis->set("awesome-{$c}-{$n}", 'swoole'));
                assert($redis->get("awesome-{$c}-{$n}") === 'swoole');
                assert($redis->delete("awesome-{$c}-{$n}"));
                $pool->put($redis);
            }
        });
    }
});
```

#### Producer and consumers

[](#producer-and-consumers)

Some Swoole's clients implement the defer mode for concurrency, but you can still implement it flexible with a combination of coroutines and channels.

```
go(function () {
    // User: I need you to bring me some information back.
    // Channel: OK! I will be responsible for scheduling.
    $channel = new Swoole\Coroutine\Channel;
    go(function () use ($channel) {
        // Coroutine A: Ok! I will show you the github addr info
        $addr_info = Co::getaddrinfo('github.com');
        $channel->push(['A', json_encode($addr_info, JSON_PRETTY_PRINT)]);
    });
    go(function () use ($channel) {
        // Coroutine B: Ok! I will show you what your code look like
        $mirror = Co::readFile(__FILE__);
        $channel->push(['B', $mirror]);
    });
    go(function () use ($channel) {
        // Coroutine C: Ok! I will show you the date
        $channel->push(['C', date(DATE_W3C)]);
    });
    for ($i = 3; $i--;) {
        list($id, $data) = $channel->pop();
        echo "From {$id}:\n {$data}\n";
    }
    // User: Amazing, I got every information at earliest time!
});
```

### Timer

[](#timer)

```
$id = Swoole\Timer::tick(100, function () {
    echo "⚙️ Do something...\n";
});
Swoole\Timer::after(500, function () use ($id) {
    Swoole\Timer::clear($id);
    echo "⏰ Done\n";
});
Swoole\Timer::after(1000, function () use ($id) {
    if (!Swoole\Timer::exists($id)) {
        echo "✅ All right!\n";
    }
});
```

#### The way of coroutine

[](#the-way-of-coroutine)

```
go(function () {
    $i = 0;
    while (true) {
        Co::sleep(0.1);
        echo "📝 Do something...\n";
        if (++$i === 5) {
            echo "🛎 Done\n";
            break;
        }
    }
    echo "🎉 All right!\n";
});
```

🔥 Amazing runtime hooks
-----------------------

[](#-amazing-runtime-hooks)

**As of Swoole v4.1.0, we added the ability to transform synchronous PHP network libraries into co-routine libraries using a single line of code.**

Simply call the `Swoole\Runtime::enableCoroutine()` method at the top of your script. In the sample below we connect to php-redis and concurrently read 10k requests in 0.1s:

```
Swoole\Runtime::enableCoroutine();
$s = microtime(true);
Co\run(function() {
    for ($c = 100; $c--;) {
        go(function () {
            ($redis = new Redis)->connect('127.0.0.1', 6379);
            for ($n = 100; $n--;) {
                assert($redis->get('awesome') === 'swoole');
            }
        });
    }
});
echo 'use ' . (microtime(true) - $s) . ' s';
```

By calling this method, the Swoole kernel replaces ZendVM stream function pointers. If you use `php_stream` based extensions, all socket operations can be dynamically converted to be asynchronous IO scheduled by coroutine at runtime!

### How many things you can do in 1s?

[](#how-many-things-you-can-do-in-1s)

Sleep 10K times, read, write, check and delete files 10K times, use PDO and MySQLi to communicate with the database 10K times, create a TCP server and multiple clients to communicate with each other 10K times, create a UDP server and multiple clients to communicate with each other 10K times... Everything works well in one process!

Just see what the Swoole brings, just imagine...

```
Swoole\Runtime::enableCoroutine();
$s = microtime(true);
Co\run(function() {
    // i just want to sleep...
    for ($c = 100; $c--;) {
        go(function () {
            for ($n = 100; $n--;) {
                usleep(1000);
            }
        });
    }

    // 10K file read and write
    for ($c = 100; $c--;) {
        go(function () use ($c) {
            $tmp_filename = "/tmp/test-{$c}.php";
            for ($n = 100; $n--;) {
                $self = file_get_contents(__FILE__);
                file_put_contents($tmp_filename, $self);
                assert(file_get_contents($tmp_filename) === $self);
            }
            unlink($tmp_filename);
        });
    }

    // 10K pdo and mysqli read
    for ($c = 50; $c--;) {
        go(function () {
            $pdo = new PDO('mysql:host=127.0.0.1;dbname=test;charset=utf8', 'root', 'root');
            $statement = $pdo->prepare('SELECT * FROM `user`');
            for ($n = 100; $n--;) {
                $statement->execute();
                assert(count($statement->fetchAll()) > 0);
            }
        });
    }
    for ($c = 50; $c--;) {
        go(function () {
            $mysqli = new Mysqli('127.0.0.1', 'root', 'root', 'test');
            $statement = $mysqli->prepare('SELECT `id` FROM `user`');
            for ($n = 100; $n--;) {
                $statement->bind_result($id);
                $statement->execute();
                $statement->fetch();
                assert($id > 0);
            }
        });
    }

    // php_stream tcp server & client with 12.8K requests in single process
    function tcp_pack(string $data): string
    {
        return pack('n', strlen($data)) . $data;
    }

    function tcp_length(string $head): int
    {
        return unpack('n', $head)[1];
    }

    go(function () {
        $ctx = stream_context_create(['socket' => ['so_reuseaddr' => true, 'backlog' => 128]]);
        $socket = stream_socket_server(
            'tcp://0.0.0.0:9502',
            $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $ctx
        );
        if (!$socket) {
            echo "$errstr ($errno)\n";
        } else {
            $i = 0;
            while ($conn = stream_socket_accept($socket, 1)) {
                stream_set_timeout($conn, 5);
                for ($n = 100; $n--;) {
                    $data = fread($conn, tcp_length(fread($conn, 2)));
                    assert($data === "Hello Swoole Server #{$n}!");
                    fwrite($conn, tcp_pack("Hello Swoole Client #{$n}!"));
                }
                if (++$i === 128) {
                    fclose($socket);
                    break;
                }
            }
        }
    });
    for ($c = 128; $c--;) {
        go(function () {
            $fp = stream_socket_client("tcp://127.0.0.1:9502", $errno, $errstr, 1);
            if (!$fp) {
                echo "$errstr ($errno)\n";
            } else {
                stream_set_timeout($fp, 5);
                for ($n = 100; $n--;) {
                    fwrite($fp, tcp_pack("Hello Swoole Server #{$n}!"));
                    $data = fread($fp, tcp_length(fread($fp, 2)));
                    assert($data === "Hello Swoole Client #{$n}!");
                }
                fclose($fp);
            }
        });
    }

    // udp server & client with 12.8K requests in single process
    go(function () {
        $socket = new Swoole\Coroutine\Socket(AF_INET, SOCK_DGRAM, 0);
        $socket->bind('127.0.0.1', 9503);
        $client_map = [];
        for ($c = 128; $c--;) {
            for ($n = 0; $n < 100; $n++) {
                $recv = $socket->recvfrom($peer);
                $client_uid = "{$peer['address']}:{$peer['port']}";
                $id = $client_map[$client_uid] = ($client_map[$client_uid] ?? -1) + 1;
                assert($recv === "Client: Hello #{$id}!");
                $socket->sendto($peer['address'], $peer['port'], "Server: Hello #{$id}!");
            }
        }
        $socket->close();
    });
    for ($c = 128; $c--;) {
        go(function () {
            $fp = stream_socket_client("udp://127.0.0.1:9503", $errno, $errstr, 1);
            if (!$fp) {
                echo "$errstr ($errno)\n";
            } else {
                for ($n = 0; $n < 100; $n++) {
                    fwrite($fp, "Client: Hello #{$n}!");
                    $recv = fread($fp, 1024);
                    list($address, $port) = explode(':', (stream_socket_get_name($fp, true)));
                    assert($address === '127.0.0.1' && (int)$port === 9503);
                    assert($recv === "Server: Hello #{$n}!");
                }
                fclose($fp);
            }
        });
    }
});
echo 'use ' . (microtime(true) - $s) . ' s';
```

⌛️ Installation
---------------

[](#️-installation)

> As with any open source project, Swoole always provides the most reliable stability and the most powerful features in **the latest released version**. Please ensure as much as possible that you are using the latest version.

### Compiling requirements

[](#compiling-requirements)

- Linux, OS X or Cygwin, WSL
- PHP 8.1.0 or later (The higher the version, the better the performance.)
- GCC 4.8 or later

### 1. Install via PECL (beginners)

[](#1-install-via-pecl-beginners)

```
pecl install swoole
```

### 2. Install from source (recommended)

[](#2-install-from-source-recommended)

Please download the source packages from [Releases](https://github.com/swoole/swoole-src/releases) or clone a specific version. Don't use `master` branch as it may be in development.

To clone the source code from git specify a tag:

```
git clone --branch v6.0.0 --single-branch https://github.com/swoole/swoole-src.git && \
cd swoole-src
```

Compile and install at the source folder:

```
phpize && \
./configure && \
make && make install
```

#### Enable extension in PHP

[](#enable-extension-in-php)

After compiling and installing to the system successfully, you have to add a new line `extension=swoole.so` to `php.ini` to enable Swoole extension.

#### Extra compiler configurations

[](#extra-compiler-configurations)

> for example: `./configure --enable-openssl --enable-sockets`

- `--enable-openssl` or `--with-openssl-dir=DIR`
- `--enable-sockets`
- `--enable-mysqlnd` (need mysqlnd, it just for supporting `$mysql->escape` method)
- `--enable-swoole-curl`

### Upgrade

[](#upgrade)

> ⚠️ If you upgrade from source, don't forget to `make clean` before you upgrade your swoole

1. `pecl upgrade swoole`
2. `cd swoole-src && git pull && make clean && make && sudo make install`
3. if you change your PHP version, please re-run `phpize clean && phpize` then try to compile

### Major change since version 4.3.0

[](#major-change-since-version-430)

Async clients and API are moved to a separate PHP extension `swoole_async` since version 4.3.0, install `swoole_async`:

```
git clone https://github.com/swoole/ext-async.git
cd ext-async
phpize
./configure
make -j 4
sudo make install
```

Enable it by adding a new line `extension=swoole_async.so` to `php.ini`.

🍭 Benchmark
-----------

[](#-benchmark)

- On the open source [Techempower Web Framework benchmarks](https://www.techempower.com/benchmarks/#section=data-r17) Swoole used MySQL database benchmark to rank first, and all performance tests ranked in the first echelon.
- You can just run [Benchmark Script](https://github.com/swoole/benchmark/blob/master/benchmark.php) to quickly test the maximum QPS of Swoole-HTTP-Server on your machine.

🔰️ Security issues
------------------

[](#️-security-issues)

Security issues should be reported privately, via email, to the Swoole develop team . You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.

🖊️ Contribution
---------------

[](#️-contribution)

Your contribution to Swoole development is very welcome!

You may contribute in the following ways:

- [Report issues and feedback](https://github.com/swoole/swoole-src/issues)
- Submit fixes, features via Pull Request
- Write/polish documentation

❤️ Contributors
---------------

[](#️-contributors)

This project exists thanks to all the people who contribute. \[[Contributors](https://github.com/swoole/swoole-src/graphs/contributors)\]. [![](https://camo.githubusercontent.com/d1e176f6f80b8c9e7d2af776dc80fffc5878041283a328435db42493d53998b5/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f73776f6f6c652d7372632f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365)](https://github.com/swoole/swoole-src/graphs/contributors)

🎙️ Official Evangelist
----------------------

[](#️-official-evangelist)

[Demin](https://deminy.in) has been playing with PHP since 2000, focusing on building high-performance, secure web services. He is an occasional conference speaker on PHP and Swoole, and has been working for companies in the states like eBay, Visa and Glu Mobile for years. You may find Demin on [Twitter](https://twitter.com/deminy) or [GitHub](https://github.com/deminy).

📃 License
---------

[](#-license)

Apache License Version 2.0 see

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance88

Actively maintained with recent releases

Popularity63

Solid adoption and visibility

Community46

Growing community involvement

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 61.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~6 days

Total

24

Last Release

57d ago

Major Versions

v5.1.5 → v6.0.0-rc12024-11-21

v5.1.6 → v6.0.02024-12-16

v5.1.7 → v6.0.22025-03-22

v5.1.8 → v6.1.0-rc12025-08-30

PHP version history (4 changes)v6.0.0-betaPHP &gt;= 8.1

v5.1.5PHP &gt;= 8.0

v6.1.1PHP &gt;=8.1 &lt;8.5

v6.2.0-rc1PHP &gt;=8.2 &lt;8.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/e1dea9261ba377a13a16e7e0f3883e73bda4094551ddea280e852f23a5d248c0?d=identicon)[Tianfeng.Han](/maintainers/Tianfeng.Han)

---

Top Contributors

[![matyhtf](https://avatars.githubusercontent.com/u/2017766?v=4)](https://github.com/matyhtf "matyhtf (7805 commits)")[![twose](https://avatars.githubusercontent.com/u/25978241?v=4)](https://github.com/twose "twose (2943 commits)")[![shiguangqi](https://avatars.githubusercontent.com/u/654869?v=4)](https://github.com/shiguangqi "shiguangqi (337 commits)")[![GXhua](https://avatars.githubusercontent.com/u/7588080?v=4)](https://github.com/GXhua "GXhua (204 commits)")[![huanghantao](https://avatars.githubusercontent.com/u/22836925?v=4)](https://github.com/huanghantao "huanghantao (170 commits)")[![NathanFreeman](https://avatars.githubusercontent.com/u/33935209?v=4)](https://github.com/NathanFreeman "NathanFreeman (161 commits)")[![shenzhe](https://avatars.githubusercontent.com/u/916634?v=4)](https://github.com/shenzhe "shenzhe (152 commits)")[![windrunner414](https://avatars.githubusercontent.com/u/31621968?v=4)](https://github.com/windrunner414 "windrunner414 (139 commits)")[![xyzhu1120](https://avatars.githubusercontent.com/u/2072473?v=4)](https://github.com/xyzhu1120 "xyzhu1120 (135 commits)")[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (76 commits)")[![Inokinoki](https://avatars.githubusercontent.com/u/8311300?v=4)](https://github.com/Inokinoki "Inokinoki (71 commits)")[![yunnian](https://avatars.githubusercontent.com/u/5779513?v=4)](https://github.com/yunnian "yunnian (65 commits)")[![sy-records](https://avatars.githubusercontent.com/u/33931153?v=4)](https://github.com/sy-records "sy-records (63 commits)")[![doubaokun](https://avatars.githubusercontent.com/u/313478?v=4)](https://github.com/doubaokun "doubaokun (49 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (46 commits)")[![betashepherd](https://avatars.githubusercontent.com/u/5636922?v=4)](https://github.com/betashepherd "betashepherd (39 commits)")[![artem-from-ua](https://avatars.githubusercontent.com/u/845773?v=4)](https://github.com/artem-from-ua "artem-from-ua (38 commits)")[![bixuehujin](https://avatars.githubusercontent.com/u/1145280?v=4)](https://github.com/bixuehujin "bixuehujin (35 commits)")[![taobao-php](https://avatars.githubusercontent.com/u/5545992?v=4)](https://github.com/taobao-php "taobao-php (32 commits)")[![recoye](https://avatars.githubusercontent.com/u/491639?v=4)](https://github.com/recoye "recoye (19 commits)")

---

Tags

concurrencycoroutineseventphpswoolewebsocket

### Embed Badge

![Health badge](/badges/swoole-swoole/health.svg)

```
[![Health](https://phpackages.com/badges/swoole-swoole/health.svg)](https://phpackages.com/packages/swoole-swoole)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
