gephart/http

Gephart HTTP Component

0.5.4 2017-10-13 19:00 UTC

This package is not auto-updated.

Last update: 2024-02-18 00:46:49 UTC


README

Build Status

Dependencies

  • PHP >= 7.1
  • psr/http-message = 1.0.1

Instalation

composer require gephart/http dev-master

Using

Request:

$request = (new Gephart\Http\RequestFactory())->createFromGlobals();

Response:

<?php

use Gephart\Http\Response;
use Gephart\Http\Stream;

class JsonResponseFactory
{
    public function createResponse($content, int $statusCode = 200, $headers = [])
    {
        $body = json_encode($content);

        $stream = new Stream("php://temp", "rw");
        $stream->write($body);

        $response = new Response($stream, $statusCode, $headers);
        return $response;
    }
}

$reponse = (new JsonResponseFactory)->createResponse(["data"=>"data"]);