qlimix/http-diactoros

This package is abandoned and no longer maintained. No replacement package was suggested.

Http helper interfaces implemented with diactoros and httphandlerrunner

1.0.0 2019-06-17 19:27 UTC

This package is auto-updated.

Last update: 2020-12-17 23:24:38 UTC


README

Travis CI Coveralls Packagist MIT License

Http helper interfaces implemented with diactoros and httphandlerrunner.

Install

Using Composer:

$ composer require qlimix/http-diactoros

usage

Request building:

<?php

use Qlimix\Http\Request\DiactorosServerRequestBuilder;

$builder = new DiactorosServerRequestBuilder();

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

Json response:

<?php

use Qlimix\Http\Response\DiactorosJsonResponse;

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

No content response:

<?php

use Qlimix\Http\Response\DiactorosNoContent;

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

Response emitting:

<?php

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

Testing

To run all unit tests locally with PHPUnit:

$ vendor/bin/phpunit

Quality

To ensure code quality run grumphp which will run all tools:

$ vendor/bin/grumphp run

Contributing

Please see CONTRIBUTING for details.