qlimix / http-laminas
Http helper interfaces implemented with Laminas diactoros and httphandlerrunner
1.0.0
2020-11-21 18:05 UTC
Requires
- php: >7.4
- laminas/laminas-diactoros: ^2.5
- laminas/laminas-httphandlerrunner: ^1.3
- psr/http-server-handler: ^1.0
- qlimix/http: ^2.0
Requires (Dev)
- qlimix/code-standard: ^3.0
This package is auto-updated.
Last update: 2024-11-22 03:39:34 UTC
README
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.