Swoole is an event-driven, asynchronous, coroutine-based concurrency library with high performance for PHP.
<?php
$server = new Swoole\Http\Server('0.0.0.0', 9501);
$server->on('start', function () {
echo "Listening at http://localhost:9501\n";
});
$server->on('request', function ($req, $res) {
$res->end('Hello, World!');
});
$server->start();
Swoole is distributed as any other PHP extension. It is easy to get started.
pecl install swoole
Or run with Docker:
docker run --rm phpswoole/swoole "php --ri swoole"