indragunawan/swoole-http-message-bridge

Swoole Http Message Bridge

v0.1.0 2020-03-19 16:18 UTC

This package is auto-updated.

Last update: 2022-05-19 20:59:07 UTC


README

license Source Packagist Travis

Provides integration Swoole Http Request / Response to Symfony Request / Response.

Installation

Require the package with composer. (indragunawan/api-rate-limit-bundle on Packagist);

composer require indragunawan/swoole-http-message-bridge

Usage

Symfony Request and Response

<?php

use Indragunawan\SwooleHttpMessageBridge\Symfony\Request;
use Indragunawan\SwooleHttpMessageBridge\Symfony\Response;

$http = new swoole_http_server(/*...*/);

$http->on('request', function (swoole_http_request $request, swoole_http_response $response) {
    $sfRequest = Request::createFromSwooleRequest($request);
    // ...
    // $sfResponse = run_something_here that return Symfony response
    Response::writeSwooleResponse($response, $sfResponse);
    // ...
    $response->end();
});

$http->start();