Alpha ZealPHP is early-stage and under active development. APIs may change between minor versions until v1.0. Feedback and bug reports welcome on GitHub.
API Index — Namespaces, Packages, Reports, Indices

ApiDispatchHandler
in package
implements RequestHandlerInterface

FinalYes

Terminal of a ZealAPI file's in-file $middleware onion. Once every in-file middleware has called its $next, this invokes the resolved api handler closure (ZealAPI::runHandlerWithContract) and turns the universal-return contract result into a PSR-7 ResponseInterface for the onion:

  • a Response passes straight through;
    • a \Generator (SSR-streaming handler) is streamed to the live response via App::emitGeneratorStream() and an empty placeholder is returned;
    • null (the handler already streamed via $this->response() / $response->sse()) yields an empty placeholder.

The handler closure + reflection-injected args are baked in at construction, so the onion holds no shared per-request state.

Table of Contents

Interfaces

RequestHandlerInterface

Properties

$api  : ZealAPI
$handler  : Closure
$invokeArgs  : array<string|int, mixed>

Methods

__construct()  : mixed
handle()  : ResponseInterface

Properties

Methods

__construct()

public __construct(ZealAPI $api, Closure $handler, array<int, mixed> $invokeArgs) : mixed
Parameters
$api : ZealAPI
$handler : Closure
$invokeArgs : array<int, mixed>

handle()

public handle(ServerRequestInterface $request) : ResponseInterface
Parameters
$request : ServerRequestInterface
Return values
ResponseInterface
On this page