Auto-gegenereerd via Reflection — blijft altijd in sync met src/.
CachingTransport
Framework\Http\CachingTransportDecorator-Transport die GET/HEAD-responses naar disk cached.
Activatie per Request via {@see Request::withCacheTtl()}; zonder ttl
gaat de call rechtstreeks naar de inner transport (geen cache, geen schrijfwerk).
Cacht alleen 2xx-responses — error-responses worden niet bewaard.
__construct(\TransportInterface $inner, string $cacheDir)2 public methods
invalidate(\Request $request): voidsend(\Request $request): \ResponseClient
Framework\Http\ClientHigh-level facade boven {@see Transport}.
Wrapt veelgebruikte patronen (get, post, postJson) en houdt de Transport
herbruikbaar — dezelfde Client kan tegen elke Transport (curl, caching,
fake-in-test) draaien.
__construct(\TransportInterface $transport, \Headers $defaultHeaders = \Framework\Http\Headers::__set_state(array(
'values' =>
array (
),
'originalCase' =>
array (
),
)))4 public methods
get(\Url|string $url): \Responsepost(\Url|string $url, ?string $body = NULL): \ResponsepostJson(\Url|string $url, array $data): \Responsesend(\Request $request): \ResponseCurlTransport
Framework\Http\CurlTransportDefault Transport-implementatie via ext-curl.
Geen automatische debug-headers, geen ingebakken cache, geen JSON-decoding.
Eén verantwoordelijkheid: bytes heen, bytes terug.
__construct(?string $caInfo = NULL)1 public method
send(\Request $request): \ResponseHeaders
Framework\Http\HeadersCase-insensitive multi-value HTTP-headers.
Behoudt de oorspronkelijke schrijfwijze van een header (`Set-Cookie` blijft
`Set-Cookie`) maar matcht op lowercase, zoals de HTTP-spec voorschrijft.
Multi-value omdat headers als `Set-Cookie` of `Via` meerdere keren mogen
voorkomen — dat ging verloren in de oude `library/Http/Headers` (die
eigenlijk een `stdClass`-string-map was).
__construct(iterable $entries = array (
))11 public methods
get(string $name): ?stringGeef de eerste waarde, of null.
getAll(string $name): arrayhas(string $name): boolnames(): arraystatic parseResponseString(string $raw): selfParse de raw response-header string van curl naar een Headers-object.
Slaat status-line en lege regels over.
toArray(): arraytoAssociative(): arraytoLines(): arrayPlaag voor logging/curl: ['Name: value', ...]. Multi-values produceren
meerdere regels.
with(string $name, string $value): selfwithAdded(string $name, string $value): selfwithout(string $name): selfHttpException
Framework\Http\HttpExceptionGegooid bij netwerk-fouten, timeouts, of niet-decodeerbare responses.
HTTP-statuscodes 4xx/5xx leveren géén exception op — die staan in {@see Response}.
__construct(string $message, ?\Request $request = NULL, ?Throwable $previous = NULL)Method
Framework\Http\MethodHTTP-methodes — compleet in tegenstelling tot library/Http/RequestMethod
(die mist PUT/PATCH/HEAD/OPTIONS terwijl HEAD wél gebruikt wordt).
4 public methods
allowsBody(): boolMag deze methode een body hebben? (Strict gezien mag GET/HEAD/DELETE wel een body, maar in praktijk doe je dat niet.)
static cases(): arraystatic from(string|int $value): staticstatic tryFrom(string|int $value): ?staticGET, POST, PUT, PATCH, DELETE, HEAD, OPTIONSRequest
Framework\Http\RequestImmutable HTTP-request value-object.
Bevat alle informatie om een aanroep te doen — maar voert 'm niet uit.
Het uitvoeren is de verantwoordelijkheid van een {@see Transport}.
Bouw via with-pattern:
$req = (new Request(Method::GET, Url::parse('https://api.example.com/v1/items')))
->withHeader('Authorization', 'Bearer …')
->withQuery(['page' => 2])
->withTimeout(5.0)
->withCacheTtl(300);
__construct(\Method $method, \Url $url, \Headers $headers = \Framework\Http\Headers::__set_state(array(
'values' =>
array (
),
'originalCase' =>
array (
),
)), ?string $body = NULL, float $timeout = 30.0, bool $followRedirects = true, bool $verifySsl = true, ?int $cacheTtl = NULL)14 public methods
cacheKey(): stringStabiele cache-key — voor {@see CachingTransport}. Sluit auth-headers uit
(Authorization, Cookie) zodat per-user requests niet de cache delen.
static get(\Url|string $url): selfstatic post(\Url|string $url, ?string $body = NULL): selfstatic postJson(\Url|string $url, array $data): selfwithBody(?string $body): selfwithCacheTtl(?int $seconds): selfwithFollowRedirects(bool $follow): selfwithHeader(string $name, string $value): selfwithHeaders(\Headers $headers): selfwithMethod(\Method $method): selfwithQuery(array $query, bool $merge = true): selfwithTimeout(float $seconds): selfwithUrl(\Url $url): selfwithVerifySsl(bool $verify): selfResponse
Framework\Http\ResponseImmutable HTTP-response: status, headers, raw body.
In tegenstelling tot library/Http/Response wordt de body NIET automatisch
gedecodeerd — dat is opt-in via {@see json()} of {@see assoc()}.
Zo blijft de raw body altijd beschikbaar voor binaire/non-JSON responses.
__construct(int $status, \Headers $headers, string $body)11 public methods
static asJson(?mixed $data, int $status = 200): selfBouw een JSON-response. Naam is `asJson` (niet `json`) omdat de
instance-methode {@see Response::json()} al bestaat als decoder voor
inkomende responses.
assoc(): arraystatic html(string $body, int $status = 200): self200 OK met `text/html`-Content-Type — de standaard voor pagina-handlers.
isClientError(): boolisOk(): boolisRedirect(): boolisServerError(): booljson(bool $associative = false): ?mixedDecodeer de body als JSON. Geeft null bij parse-fouten.
Gebruik {@see assoc()} als je een associative-array wil.
static notFound(string $body = '404 Not Found'): self404 met optionele body — handig in een fallback-route.
static redirect(string $location, int $status = 302): self302 Found (default) of een andere 3xx; lege body, alleen `Location`-header.
static text(string $body, int $status = 200): self200 OK met `text/plain`-Content-Type.
ServerRequest
Framework\Http\ServerRequestInbound HTTP-request — de aanvraag die de server ontvangt.
Naast de PSR-7-achtige opzet (method/url/headers/body) zit er ergonomie op:
- query/body als {@see Parameters} → typed coercion via define()
- cookies als Parameters
- JSON-body wordt automatisch geparsed als Content-Type application/json is
(PHP's $_POST is dan leeg)
- clientIp() kijkt naar X-Forwarded-For voor reverse-proxies
Immutable: with*-methodes geven een nieuwe instance terug. Routes gebruiken
dat om route-params toe te voegen zonder de "huidige" request te muteren.
__construct(\Method $method, \Url $url, \Headers $headers, \Parameters $query, \Parameters $body, \Parameters $cookies, string $rawBody = '', array $routeParams = array (
))7 public methods
static capture(): selfBouw een ServerRequest uit globals (PHP-FPM / mod_php). Voor tests:
gebruik de constructor direct met je eigen waarden.
clientIp(array $trustedProxies = array (
)): stringGeeft het IP van de client. Vertrouwt X-Forwarded-For alleen als REMOTE_ADDR
in $trustedProxies staat — anders gebruik je domweg REMOTE_ADDR.
isAjax(): boolisJson(): boolisPost(): boolparam(int $index, string $default = ''): stringRoute-parameter op positie-index (capture-group uit het pattern).
withRouteParams(array $params): selfTransportInterface
Framework\Http\TransportInterfaceStuurt een {@see Request} de wereld in en levert een {@see Response} op.
Implementaties:
- {@see CurlTransport} — echte HTTP-call via curl
- {@see CachingTransport} — decorator die cache-hits buiten de inner-transport om afhandelt
- tests gebruiken meestal een eigen FakeTransport
1 public method
send(\Request $request): \ResponseUrl
Framework\Http\UrlImmutable URL-value-object met fluent with*-pattern voor query-merging.
Vervangt de mix van parse_url + http_build_query + handmatige fallback
uit library/Http/Request.
__construct(string $scheme = 'https', string $host = '', ?int $port = NULL, string $path = '/', array $query = array (
), ?string $fragment = NULL, ?string $user = NULL, ?string $pass = NULL)6 public methods
static parse(string $url): selfrelative(): stringPad + query + fragment, zónder scheme/host.
withParam(string $name, ?mixed $value): selfVoeg/overschrijf één query-parameter.
withPath(string $path): selfwithQuery(array $extra, bool $merge = true): selfwithoutParam(string $name): selfVerwijder één query-parameter.
ImageHandler
Framework\Image\Http\ImageHandlerHTTP-handler voor `/img/...`-routes.
Flow:
1. Parse URL → ParsedUrl (intern hash óf extern URL + sig-verify)
2. Variant-cache check → hit: serve direct, miss: stap 3
3. Resolve source-bytes (FileStorage óf remote-fetch+ingest)
4. StillFrame-extractie (passthrough / GIF frame 0 / video frame via ffmpeg)
Voor video: tussencache zodat ffmpeg niet per maat opnieuw runt
5. Transform via backend
6. Schrijf naar variant-cache zodat nginx volgende requests direct serveert
__construct(\UrlParser $urlParser, \FileStorageSource $internalSource, \RemoteUrlSource $remoteSource, \StillFrameRegistry $stillFrames, \Transformer $transformer, \VariantCache $variantCache, \VariantCache $frameCache)