kdubuc / invocator-php
Handles HTTP requests using stdio
dev-master
2019-02-27 11:05 UTC
Requires
- php: ^7.3
- guzzlehttp/psr7: ^1.5
- psr/http-server-handler: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-10-28 00:14:34 UTC
README
<?php require_once __DIR__.'/vendor/autoload.php'; use function Kdubuc\Invocator\invoke; use My\Custom\RequestHandler; $action = new RequestHandler(); invoke($action, STDIN, STDOUT);
Invoke's job is to marshal a raw HTTP request incomming into its input resource to build a PSR-7 ServerRequest object, invoke your chosen PSR-15 RequestHandler with that, and to respond with a raw HTTP Response message issued by the RequestHandler.
Invoke uses stdio as an interface between the API gateway and your RequestHandler.
Can be useful in a Serverless context (API Gateway -> Tiny HTTP server like kdubuc/watchdog -> Invoke).