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':

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

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

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

$server->on("request", function (Request $request, 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!