gephart / http
Gephart HTTP Component
0.5.5
2024-06-24 13:44 UTC
Requires
- php: >=7.1
- psr/http-message: 1.0.1
Requires (Dev)
- phpmd/phpmd: @stable
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: 6.0.*
- squizlabs/php_codesniffer: ^3.0
README
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"]);