phrity/http
Phrity Http provides small PSR-friendly utilities for HTTP in PHP. Includes an HttpFactory wrapper that combines PSR-17 factories (or auto-configures from a single implementation) and a Serializer that converts PSR-7 requests/responses/messages to raw HTTP strings.
HttpFactory enables seamless switching between implementations without refactoring business logic.Serializer provides raw HTTP message dumps (requests/responses) for logging, monitoring, and troubleshooting in distributed systems. Critical for API gateways, service meshes, or Laravel applications with complex HTTP integrations.HttpFactory to replace external API dependencies in unit/integration tests, reducing flakiness and improving CI/CD reliability. Complements Laravel’s Http::fake() but offers PSR-7 flexibility.HttpFactory to include PSR-15 middleware support.HttpClient, Guzzle, or Nyholm PSR-7).For Executives: "This package standardizes how our PHP services handle HTTP traffic, reducing complexity and costs. By consolidating PSR-17 implementations (e.g., Guzzle vs. Nyholm), we eliminate vendor lock-in and simplify maintenance. The built-in serializer also gives us superior debugging—we can log raw HTTP messages to quickly diagnose API issues, which is critical for our [e.g., payment processing, third-party integrations]. It’s a low-risk investment (MIT license, PSR-compliant) with high rewards for scalability and observability."
For Engineering:
*"The HttpFactory lets us compose PSR-17 factories dynamically, while the Serializer gives us a clean way to log/inspect HTTP messages. Here’s how it helps:
Log::info($serializer->request($request))).
Works with Laravel via PSR-17 adapters (e.g., nyholm/psr7). Just composer require phrity/http—minimal setup, maximum flexibility.*For Developers: *"This package solves two key pain points:
HttpFactory handles it.Serializer turns opaque HTTP messages into readable strings—perfect for logging or debug bars.
Example use case: Replace this:$request = new \Nyholm\Psr7\Request('GET', '/');
With this:
$factory = HttpFactory::create(new \Nyholm\Psr7\HttpFactory());
$request = $factory->createRequest('GET', '/');
Bonus: Use the serializer to log requests like Log::debug($serializer->request($request))."*
How can I help you explore Laravel packages today?