Get Started with Swoole

Swoole is released as a PHP extension (PECL) and runs as a PHP CLI application, just like php server.php.

Try it with Docker

Please check the Try Swoole with Docker guide.


Please check the prerequisites and installation guide.

Hello world

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

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 on the command line:

// Start the HTTP server
$ php server.php

// On another terminal...
$ curl

Interested with Swoole? Get Started with Swoole now!