Localzet Server and related projects documentation

PSR-7: getting started

Installation

composer require localzet/psr7:^4.0

Package 4.x targets Localzet Server 7.

First example

use localzet\PSR7\Request;
use localzet\PSR7\Response;
use localzet\PSR7\Stream;

$body = fopen('php://temp', 'r+');
fwrite($body, '{"name":"item"}');
rewind($body);
$request = (new Request('POST', 'https://api.example.test/items'))
    ->withHeader('Content-Type', 'application/json')
    ->withBody(new Stream($body));
$response = new Response(201, ['Content-Type' => 'application/json']);

Check compatibility and limitations in API and operations before using the package in an application.