kriswallsmith/buzz
Buzz is a lightweight PHP HTTP client library with a simple API for sending requests and handling responses. It supports PSR-7 messages and PSR-18 clients, integrates with common transports, and is ideal for quick integrations, APIs, and webhooks.
HttpClient facade).php-http/message and php-http/client), reducing versioning risks.laravel/http-client).Client::sendRequest()).MockHttp for testing HTTP interactions.HttpClient presets).HttpClient or Guzzle for external APIs needing advanced features.HttpClient facade or run independently?file_get_contents() or curl calls.// app/Providers/BuzzServiceProvider.php
public function register()
{
$this->app->singleton('buzz', function () {
return new \Buzz\Client();
});
}
// app/Facades/Buzz.php
public static function send(string $method, string $url, array $options = []): ResponseInterface
{
return app('buzz')->send(new Request($method, $url, $options));
}
Http::get()/GuzzleHttp calls with Buzz::send() in targeted areas.php-http/message, compatible with Laravel’s Psr\Http\Message interfaces.HttpClient by wrapping it in a custom adapter:
use Illuminate\Support\Facades\Http;
use Buzz\Client;
Http::macro('buzz', function (string $url, array $options = []) {
$client = new Client();
$request = new Request('GET', $url, $options);
$response = $client->send($request);
return new \Illuminate\Http\Client\Response(
$response->getStatusCode(),
$response->getHeaders(),
$response->getBody()->getContents()
);
});
sync:work or async queues).| Phase | Task | Dependencies |
|---|---|---|
| Discovery | Audit existing HTTP calls (Guzzle, file_get_contents, etc.). |
None |
| Setup | Install Buzz, configure Service Provider/Facade. | PHP 8.1+, Laravel 8+ |
| Pilot | Replace 1–2 HTTP calls; test performance. | Buzz integration |
| Middleware | Build custom middleware (e.g., logging, retries) if needed. | Buzz client instance |
| Document | Update API docs with Buzz usage patterns. | Pilot results |
| Rollout | Replace remaining internal HTTP calls. | Approval from Phase 2 |
| Deprecate | Phase out old HTTP clients (e.g., Guzzle for internal calls). | Full Buzz adoption |
HttpClient presets) must be manually implemented.php-http/message updates for breaking changes.app/Services/HttpService.php).Buzz\Handler\HandlerStack, but lacks Laravel’s HttpClient debugging helpers.4xx/5xx), but lacks Laravel’s HttpClient exceptions (e.g., ConnectionException).$handler = new HandlerStack();
$handler->push(function (RequestInterface $request, callable $next) {
try {
return $next($request);
} catch (Exception $e) {
throw new \Illuminate\Http\Client\ConnectionException($e->getMessage());
}
});
Http\Adapter\Guzzle6).Buzz\Handler\CurlHandler with custom pooling or switch to react/http for async.Buzz\Handler\SocketHandler for high concurrency).| Failure Scenario | Impact | Mitigation Strategy |
|---|---|---|
| HTTP Timeouts | Request hangs indefinitely. | Set timeouts in Request options. |
How can I help you explore Laravel packages today?