Front-Interop Now Open For Public Review
I am pleased to announce that the Front-Interop standard interface package is now open for public review.
Front-Interop provides an interoperable package of standard interfaces for front controller functionality in any execution context (HTTP, CLI, etc.). It reflects, refines, and reconciles the common practices identified within several pre-existing projects.
The central interface is FrontController, which affords an entry point
into the outermost presentation layer. Its only method, run(), returns an
integer exit status code: 0 for success, 1 to 254 for non-success.
Returning an exit status is a deliberate departure from the majority practice of returning void or a
response object. Doing so allows the same
interface to be used across many different execution contexts:
HTTP, command line, queue workers, CI runners, and long-running processes
alike.
The reference implementations demonstrate the interface contract across different execution contexts:
-
RequestFrontController reads
$_GET, emits HTML, and setshttp_response_code()for a traditional HTTP server context. -
FrankenFrontController wraps RequestFrontController inside a
frankenphp_handle_request()worker loop, demonstrating the same interface in a long-running FrankenPHP worker context. -
ConsoleFrontController reads
$argvand writes to injected$stdoutand$stderrresources for a command line context.
These implementations are intentionally naive -- no router, no IOC container, no request or response -- to highlight the front controller specifics.
Please offer your comments and criticism as issues or PRs out at Github.