juliangut/server-handler-swoole

dev-master 2020-02-20 11:39 UTC

This package is auto-updated.

Last update: 2020-12-20 13:45:49 UTC


README

PHP version Latest Version License

Build Status Style Check Code Quality Code Coverage

Total Downloads Monthly Downloads

juliangut/server-handler-swoole

Easily run Swoole server with any implementation of PSR-15 RequestHandlerInterface

Installation

Composer

composer require juliangut/server-handler-swoole

Usage

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

Contributing

Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.

See file CONTRIBUTING.md

License

See file LICENSE included with the source code for a copy of the license terms.