Get Started with Open Swoole

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Open Swoole is released as a PHP PECL (PHP Extension Community Library) extension (written in C++) and runs as a PHP CLI application, simply by running $ php server.php. You can read more about the PECL Repository and even browse extensions like Open Swoole. Using the PECL Repository is an official way to install additional extensions to the PHP language, you can think of it like an add-on/plug-in which gets compiled, installed and loaded with PHP.

There a are a few ways to install Open Swoole on different systems, at first it can seem complicated if you have never installed a PHP extension before but once you read the basics its actually really easy and simple.

Try it with Docker

Please check the Try Open Swoole with Docker guide.

OpenSwoole Components

OpenSwoole Extension Installation

Please check the prerequisites first and then the installation guide.

Open Swoole can be installed via PECL, Open Swoole PPA Repository (Ubuntu or Debian) or manually by compiling source code from GitHub.

OpenSwoole Core Installation

composer requrie openswoole\core

Latest Updates

As with any open source project, Open Swoole always aims to provide 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 of Open Swoole and PHP.

Hello World

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


use OpenSwoole\Http\Server;
use OpenSwoole\Http\Request;
use OpenSwoole\Http\Response;

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

$server->on("Start", function(Server $server)
    echo "OpenSwoole 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 Open Swoole? Get Started with Open Swoole now!


Because Open Swoole uses multiple processes and uses a stateful program model, some PHP applications rely heavily on super globals which could lead to a process crash when using Open Swoole, so currently the following software is incompatible with Open Swoole:

  • Xdebug
  • phptrace
  • aop
  • molten
  • xhprof
  • Phalcon
  • BlackFire

You should read Open Swoole Tools for more information on alternatives.

Run all ext-openswoole tests at local

export PHP_VERSION=8.2
export CI_BRANCH=master
Last updated on February 7, 2023