PHP code example of qlimix / http-diactoros

1. Go to this page and download the library: Download qlimix/http-diactoros library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qlimix / http-diactoros example snippets




use Qlimix\Http\Request\DiactorosServerRequestBuilder;

$builder = new DiactorosServerRequestBuilder();

$builder->build();
$builder->buildFromGlobals();



use Qlimix\Http\Response\DiactorosJsonResponse;

$response = new DiactorosJsonResponse();
$response->response([], 200, ['x-foo' => 'foobar']);



use Qlimix\Http\Response\DiactorosNoContent;

$response = new DiactorosNoContent();
$response->noContent();



use Qlimix\Http\Response\HandlerRunnerResponseEmitter;
use Qlimix\Http\Response\DiactorosJsonResponse;
use Zend\HttpHandlerRunner\Emitter\SapiEmitter;

$responseCreation = new DiactorosJsonResponse();
$response = $responseCreation->response([], 200, ['x-foo' => 'foobar']);

$emitter = new SapiEmitter();
$responseEmitter = new HandlerRunnerResponseEmitter($emitter);
$responseEmitter->emit($response);