Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 1.6 KB

README.md

File metadata and controls

39 lines (28 loc) · 1.6 KB

Swoole Http Message Bridge

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