kuick / http
Kuick HTTP is a slim PSR-15 implementation
v1.0.1
2025-01-22 09:37 UTC
Requires
- php: >=8.2.0
- nyholm/psr7: ^1.8
- nyholm/psr7-server: ^1.1
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
- psr/log: ^3.0
Requires (Dev)
- kuick/qa-toolkit: ^1.0
Provides
README
Kuick PSR-15 implementation of HTTP Server Request Handlers
Key features
- PSR-15 (https://www.php-fig.org/psr/psr-15/) implementation
- PSR-7 Response Emitter
- PSR-7 Response implementation with JsonResponse extension
- Handful HTTP error based Exception collection
Examples
- Using RequestHandler
<?php
use Kuick\Http\RequestHandler;
use Kuick\Http\Server\ExceptionJsonRequestHandler;
use Nyholm\Psr7\ServerRequest;
use Psr\Log\NullLogger;
$request = new ServerRequest('GET', '/something');
// request handler needs a fallback, exception handling handler
$exceptionHandler = new ExceptionJsonRequestHandler(new NullLogger());
$handler = new RequestHandler($exceptionHandler);
$response = $handler->handle($request);
// 404, the response implements PSR-7 ResponseInterface
echo $response->getStatusCode();
- Emitting PSR-7 response
<?php
use Kuick\Http\Message\JsonResponse;
use Kuick\Http\Server\ResponseEmitter;
$emitter = new ResponseEmitter();
$response = new JsonResponse(['message' => 'test']);
$emitter->emitResponse($response);