qlimix/http-laminas

Http helper interfaces implemented with Laminas diactoros and httphandlerrunner

1.0.0 2020-11-21 18:05 UTC

This package is auto-updated.

Last update: 2021-11-21 20:42:17 UTC


README

Travis CI Coveralls Packagist MIT License

Http helper interfaces implemented with diactoros and httphandlerrunner.

Install

Using Composer:

$ composer require qlimix/http-laminas

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\LaminasHandlerRunnerResponseEmitter;
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 LaminasHandlerRunnerResponseEmitter($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.