kdubuc/invocator-php

Handles HTTP requests using stdio

dev-master 2019-02-27 11:05 UTC

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