Get started with Swoole

Swoole is released as a PHP extension (PECL) and run as a PHP CLI.

Try it with Docker

Please check the Try Swoole with Docker


Please check the prerequisites and installation guide.

Hello world

The following code is a Swoole HTTP Server returning 'Hello World':

$http = new Swoole\HTTP\Server("", 9501);

$http->on('start', function (Swoole\Http\Server $server) {
    echo "Swoole http server is started at\n";

$http->on('request', function (Swoole\Http\Request $request, Swoole\Http\Response $response) {
    $response->header("Content-Type", "text/plain");
    $response->end("Hello World\n");


To run the server, put the code into a file named server.php. Then execute it with PHP CLI:

$ php server.php
$ curl

Interested with Swoole? Get Started with Swoole now!