-
Notifications
You must be signed in to change notification settings - Fork 0
Recipes
Muhammet Şafak edited this page May 24, 2026
·
1 revision
Task-oriented walk-throughs. Each one is self-contained — copy, paste, adapt.
| Recipe | What it covers |
|---|---|
| JSON Response | Convenience producer, manual variants, RFC 9457 Problem Details, streaming JSON. |
| Redirect | 301 / 302 / 303 / 307, delayed redirect, sticky session cookies. |
| File Upload | Receiving uploads (single, simple array, nested), sending multipart bodies. |
| Streaming Large Files | Multi-MB downloads/uploads without loading into memory; SSE caveat. |
| Proxying Requests | Incoming ServerRequest → outgoing PSR-18 Request → emit response back. |
These are deliberately not covered here — they're the domain of higher-level libraries:
-
PSR-15 middleware pipelines. Use
relay/relay,laminas/laminas-stratigility, or your framework's built-in pipeline. - Authentication / authorisation. Up to your auth library; this package gives you the request/response value objects to act on.
-
Routing. Use
nikic/fast-route,league/route, or your framework's router. - CSRF / CORS. Middleware concerns; many PSR-15 middlewares exist.
-
Caching of upstream responses. Wrap the
Clientin your own decorator, or usekevinrob/guzzle-cache-middleware-style adapters that target your chosen PSR-18 client. -
Multipart encoding. PSR-7 has no opinion on multipart encoding; use
guzzlehttp/psr7'sMultipartStream,symfony/mime, or build the body yourself — see the File Upload recipe for an example.
Open an issue at github.com/InitPHP/HTTP/issues describing the scenario; recipe additions are reviewed eagerly.
initphp/http · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
PSR-7 Messages
PSR-17 Factories
PSR-18 Client
Emitter (SAPI)
Static Facades
Recipes
Reference
Migration & Help