php-http-psr

Implements framework-agnostic PHP HTTP handling using PSR-7, PSR-15, PSR-17, and PSR-18 interfaces.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill php-http-psr-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: php-http-psr
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/php-expert/skills/php-http-psr
Command: npx skills add https://github.com/fusengine/kimi-code --skill php-http-psr-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing HTTP code in PHP libraries often couples the code to a specific framework or client, making it hard to reuse and swap implementations. This Skill guides you to build HTTP messages, middleware pipelines, factories, and clients purely against the PSR interfaces, so any compliant implementation can be injected. ## Core Features & Use Cases - PSR-7 Messages: Build and read immutable requests, responses, streams, and URIs with correct with*() reassignment patterns. - PSR-15 Middleware Pipelines: Compose request handlers and middleware with a complete runnable dispatcher template, including error-handler-first ordering and short-circuit auth. - PSR-17 Factories & PSR-18 Clients: Create PSR-7 objects without naming concrete classes and send outbound requests with the correct exception hierarchy (4xx/5xx are responses, not exceptions). - Implementation Selection: Compare nyholm/psr7, guzzlehttp/psr7, and laminas-diactoros, and bridge Symfony HttpFoundation via symfony/psr-http-message-bridge. - Use Case: You are writing a reusable PHP package that calls an external API. Inject a RequestFactoryInterface and ClientInterface so consumers can wire Guzzle, Symfony HttpClient, or any PSR-18 client without changing your code. ## Quick Start Ask the agent to build a PSR-15 middleware pipeline with an error handler and auth middleware using nyholm/psr7 as the implementation.

Frequently Asked Questions about php-http-psr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a PSR-15 middleware pipeline in PHP?▼

Implement a dispatcher class implementing RequestHandlerInterface that pops middleware from a queue and calls process() with itself as the next handler. Place an error-catching middleware first, and end the queue at a terminal handler that produces the response.

Which PSR-7 implementation should I choose: nyholm, guzzle, or laminas?▼

nyholm/psr7 is the default recommendation: lightweight, strict, and ships one Psr17Factory covering all six PSR-17 factories. Choose guzzlehttp/psr7 if you use the Guzzle client or need stream decorators, and laminas-diactoros in Laminas/Mezzio stacks.

Why does withHeader() not change my PSR-7 request?▼

PSR-7 messages are immutable: every with*() method returns a new instance and leaves the original unchanged. You must reassign the result, for example $request = $request->withHeader('X-Api-Key', 'secret'), or the call is a silent no-op.

Does a PSR-18 client throw an exception on 404 or 500 responses?▼

No. PSR-18 clients MUST return 4xx and 5xx as normal responses. They only throw ClientExceptionInterface subclasses for transport failures (NetworkExceptionInterface) or malformed requests (RequestExceptionInterface).

Can I use Symfony HttpFoundation with PSR-7 code?▼

Symfony's Request/Response are a separate, mutable model that does not implement PSR-7 interfaces. Use symfony/psr-http-message-bridge to convert between HttpFoundation and PSR-7 messages in both directions.

When should I not use this PSR-based approach?▼

Avoid it when working inside Laravel's own HTTP layer or Symfony HttpFoundation directly, since those are not PSR-7 models. Route Laravel HTTP work to a Laravel-specific skill and bridge to PSR-7 only when interoperability is required.