Swoole documents

Swoole is an high-performance network extension using an event-driven, asynchronous, non-blocking I/O model and coroutine.

Swoole is designed for building large scale concurrency systems. It is written in C/C++ and installed as a PHP extension.

PHP developers can use Swoole to write high-performance, scalable, concurrent TCP, UDP, Unix Socket, HTTP, WebSocket services with PHP syntax. Don't have to know too much about non-blocking I/O programming and low-level Linux kernel.

Compared with other Async programming frameworks or software such as Nginx, Tornado, Node.js, Swoole is a PHP Async solution has the built-in async, coroutine support, multiple threads I/O modules.

Developers can use Sync or Async API to write the applications.

Swoole PHP network extension enhances the efficiency of the R&D team, enable them to focus on the development of innovative products.

Swoole follows the similar principle from Erlang, Node.js and Netty, but for PHP.

The Swoole extension is released as a PHP extension (PECL) and runs as a PHP CLI application.

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");


Interested with Swoole? Get Started with Swoole now!

You can also check the Swoole Error Codes.


Swoole Documentation
PHP Coroutine
Coroutine Client