Easily run Swoole server with any implementation of PSR-15 RequestHandlerInterface
composer require juliangut/server-handler-swoole
Require composer autoload file
require './vendor/autoload.php';
use Jgut\ServerHandler\Swoole\Http\PsrRequestFactory;
use Jgut\ServerHandler\Swoole\Http\SwooleResponseFactory;
use Swoole\Http\Server as SwooleServer;
$swooleServer = new SwooleServer('127.0.0.1', 8080, \SWOOLE_BASE, \SWOOLE_SOCK_TCP);
$swooleServer->set([
'max_conn' => 1024,
'enable_coroutine' => false,
]);
$requestFactory = new PsrRequestFactory(
/* \Psr\Http\Message\ServerRequestFactoryInterface */,
/* \Psr\Http\Message\UriFactoryInterface */,
/* \Psr\Http\Message\StreamFactoryInterface */,
/* \Psr\Http\Message\UploadedFileFactoryInterface */
);
$responseFactory = new SwooleResponseFactory();
$server = new Server(
$swooleServer,
/* Psr\Http\Server\RequestHandlerInterface */,
$requestFactory,
$responseFactory,
true
);
$server->run();
Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.
See file CONTRIBUTING.md
See file LICENSE included with the source code for a copy of the license terms.